This appears to occur because only the source code is compiling when you use mvn clean compile
(I'm using maven 3.1.0 so I'm not sure if it always behaved like this).
If you run mvn test
, the test code will compile as well, but then it runs the tests (which may not be immediately desirable if you're trying to run them through Eclipse.) The way around this is to add test-compile
to your Maven command sequence whenever you do a mvn clean
. For example, you would run mvn clean compile test-compile
.