当我的 pom 设置为包装类型“pom”时,我在运行单元测试时遇到了一些问题。起初,它说这个项目不需要目标,所以我将 maven-surefire-plugin 添加到我的 pom.xml 以将测试阶段绑定到 maven-surefire-plugin 测试目标。
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.9</version>
<executions>
<execution>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
</execution>
</executions>
</plugin>
现在,surefire 插件正在执行,但它说没有要运行的测试。如果我将包装类型更改为 jar 并运行 mvn test 然后它会拾取我的测试文件。
当我运行 mvn test -X 时,它显示“testSourceDirectory = C:\dev\dsl\src\test\java”,这是正确的位置。包装类型“pom”与“jar”的测试位置是否不同?我尝试添加
<configuration>
<testSourceDirectory>src/test/java</testSourceDirectory>
</configuration>
到surefire插件,但它根本没有帮助。