我的 maven 存储库中有一个 jar,其中包含 junit 测试,它应该在不同的项目中运行,因为它能够检查项目并测试它的某些功能。不幸的是,surefire 不会提取包含在 jar 中的测试,正如此Feature Request 所示。
在功能请求中,他们建议解压 jar,然后由 surefire 执行。
我使用 maven-dependency-plugin 成功解压缩了 jar,但无论如何都不会执行包含的测试。这就是我配置 maven-dependency-plugin 以解压缩我的 jar 的方式:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>unpack</id>
<phase>process-test-classes</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>de.mwx.test</groupId>
<artifactId>selenium-test-base</artifactId>
<version>0.1</version>
<overWrite>true</overWrite>
<outputDirectory>
${project.build.directory}/classes
</outputDirectory>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
任何帮助都将不胜感激。