I had the same problem with STS Eclipse (Spring development variant), m2e and JUnit. The solution was to set the output folder for src/test/java
to target/test-classes
:
- Right click the
src/test/java
folder in the Package Explorer - Select Build Path -> Configure Output Folder
- Enter
target/test-classes
, click OK
Now the changes in test classes are compiled correctly and you should be able to run JUnit tests in Eclipse.
The problem is that Eclipse compiles the unit tests to the default output folder target/classes
while JUnit plugin correctly tries to run them from test-classes
.
There are a few duplicates to this question: