I got a little trouble using maven and junit. Running junit test on its own works perfect, but building with Maven mvn clean test fails. I made sure that all tests are within "src/test/java" and all sources are within "src/main/java", so junit can find them (regarding to other questions this was the problem in many other cases).
So does anybody knows why I this is not working for me?
Error Message snipped:
/D:/pathToProject/myProject/src/test/java/myPackage/MyFile.java:[5,17] package org.junit does not exist Pom.xml Snipped:
<...project information.../> <build> <sourceDirectory>src</sourceDirectory> <plugins> <plugin> <artifactId>maven-compiler-plugin</artifactId> <version>3.1</version> <configuration> <source /> <target /> </configuration> </plugin> </plugins> <plugins> </plugins> </build> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.11</version> <scope>test</scope> </dependency> </dependencies> </project>
<sourceDirectory>src</sourceDirectory>which does not make sense. Remove it. Furthermore i would suggest to use<source>1.5</source>and<target>1.5</target>at least or may be 1.6/1.7.