Problems running unit tests after a 'Move..' refactoring
I'm running Eclipse Helios and using the wip_exp_backport (http://download.scala-ide.org/nightly-update-wip-exp-backport-2.8.1.final) version of Scala IDE. I updated this morning to version 1.0.0.201102220002, but I believe that I have seen this issue before. I am also using the M2Eclipse Maven plugin.
This morning, I did an update and checked out my Scala project via EGit. The project is a Scala project, but I also use M2Eclipse to build it with Maven. After a checkout and build, I right-clicked on my 'src/test/scala' source directory, and did a 'Run As' -> 'JUnit Test', where all of my tests ran successfully. I then decided to move one of the tests into a sub-package, so I right-clicked on the .scala file and did a 'Refactor...' -> 'Move...' and selected a new package. Performing that refactoring did not update the 'package' declaration in the Scala file, so I adjusted it myself. I then did a clean and rebuild of the project.
After this refactoring, I could not get the JUnit runner to find the moved file. Running tests via Maven outside of Eclipse worked fine. I tried deleting the 'target' directory under the project and rebuilding. The build ran fine in Eclipse, but the JUnit runner still couldn't find the test class. There were no obvious errors, the test runner was simply now showing fewer test than it had before. I was finally able to resolve the issue by checking in my modified code, blowing away the Eclipse project, and checking it back out again as a new project. At that point, the tests started working fine.
This morning, I did an update and checked out my Scala project via EGit. The project is a Scala project, but I also use M2Eclipse to build it with Maven. After a checkout and build, I right-clicked on my 'src/test/scala' source directory, and did a 'Run As' -> 'JUnit Test', where all of my tests ran successfully. I then decided to move one of the tests into a sub-package, so I right-clicked on the .scala file and did a 'Refactor...' -> 'Move...' and selected a new package. Performing that refactoring did not update the 'package' declaration in the Scala file, so I adjusted it myself. I then did a clean and rebuild of the project.
After this refactoring, I could not get the JUnit runner to find the moved file. Running tests via Maven outside of Eclipse worked fine. I tried deleting the 'target' directory under the project and rebuilding. The build ran fine in Eclipse, but the JUnit runner still couldn't find the test class. There were no obvious errors, the test runner was simply now showing fewer test than it had before. I was finally able to resolve the issue by checking in my modified code, blowing away the Eclipse project, and checking it back out again as a new project. At that point, the tests started working fine.
Leave a comment
Updating tickets (#1000199, #1000200, #1000201, #1000204, #1000205, #1000209, #1000210, #1000211, #1000212, #1000215, #1000217, #1000218, #1000220, #1000222, #1000226, #1000227, #1000228, #1000230, #1000231, #1000232, #1000233, #1000235, #1000236, #1000237, #1000239, #1000240, #1000241, #1000242, #1000243, #1000244, #1000248, #1000249, #1000252, #1000253, #1000254, #1000255, #1000256, #1000258, #1000259, #1000032, #1000059, #1000062, #1000163, #1000197, #1000216, #1000221, #1000224, #1000121, #1000175, #1000219, #1000251, #1000069, #1000195, #1000213, #1000223, #1000006, #1000021, #1000038, #1000048, #1000051, #1000052, #1000075, #1000103, #1000109, #1000115, #1000119, #1000156, #1000186, #1000207, #1000238, #1000262, #1000263, #380, #389, #683, #1238, #1331, #1635, #1645, #1715, #1729, #1744, #1783, #1839, #1869, #1885, #1890, #1902, #1918, #1919, #1924, #1925, #1946, #1964, #1991, #2131, #2233, #2342, #2348, #2408)