Reputation: 4369
Hmm, I don't think I ever had a problem like this. JUnit totally ignores whatever changes I make in the *.java file of the test. Once I run it it just executes the old order. I tried adding a new code, it still executes the same, I tried commenting out other test cases in this class, it still executes them as if it was all cached. I tried cleaning the whole project but it doesn't help. I tried reopening Eclipse, didn't help as well...
The only thing that helped me to get my test executed correctly with my changes was to create a clone class with the copied code with a different name of the class, then JUnit actually executed the changed code instead of using the cached version then, but this is more of a workaround then a solution, I would like to know what the solutions to this could be?
I'm using JUnit 4.11:
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
</dependency>
And I really don't think I ever had this issue before... I maybe have had some problems with the VM ignoring changes in the code some time ago, that would usually get solved by doing a clean on the project, but never had problems with JUnit like this. And I couldn't really find posts relating to an issue like this.
Upvotes: 0
Views: 1507
Reputation: 115378
JUnit itself does not compile anything and does not decide what to compile and does not have any cache. Other tools like IDE or build tool are responsible on it.
If you are running tests from Eclipse I believe that this is the Eclipse problem. Open menu item "project" and see whether "Build Automatically" checkbox is selected.
If this does not help, try to create project again. If this does not help, create whole workspace again.
Upvotes: 2