我有这么多的java文件和那些java文件test.java不在src/test/java结构中。例如: 例如:我在src/java/abc中有一个名为abc.java的java文件,但是这个名为abcTest.java的java文件的测试文件位于src/java/junit/abc中。 因此,我将如何通过maven pom.xml来执行此java文件的junit测试,因为maven需要src/main/java中的正常java文件并在src/test/java中测试文件,所以我将如何通过maven进行测试?如何在Maven测试文件不在mavenise结构中运行Junit测试
我在我的pom.xml中添加了junit dependency和surefire插件。
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
和万无一失插件
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.10</version>
<configuration>
<testSourceDirectory>${basedir}/../src/java/junit/*.java</testSourceDirectory>
<testClassesDirectory>${project.build.directory}/classes/</testClassesDirectory>
<includes>
<include>abcTest.java</include>
</includes>
</configuration>
</plugin>
我已经给MVN测试命令,但它仍然是给在日志零次测试。任何人都可以帮助我如何通过maven运行junit test.java文件?
为什么你需要这种结构? – asg
我不需要任何结构 –
对不起,如果我困惑你。我的观点是你为什么想把JUnit类放在你的源代码中,你需要使用pom.xml来运行它? – asg