【发布时间】:2015-03-14 15:14:46
【问题描述】:
我有以下故障安全设置,当我“正常”运行时它按预期工作(= 使用 mvn 验证,并且不使用 dependenciesToScan):
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.18.1</version>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
<configuration>
<failIfNoTests>true</failIfNoTests>
<suiteXmlFiles>
<suiteXmlFile>src/test/resources/mySuite.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
- 集成测试按预期运行,
- 如果没有指定测试,验证会按预期爆炸,并且
- 当集成测试失败时,构建会在验证阶段中断
但是,当我采用完全相同的故障安全设置并在“test-runner”pom / 项目中使用“dependenciesToScan”扩展它时,该项目只运行 jar 文件中的测试(所以我不会重新编译/重建每次我想运行集成测试时整个项目):
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.18.1</version>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
<configuration>
<failIfNoTests>true</failIfNoTests>
<suiteXmlFiles>
<suiteXmlFile>src/test/resources/mySuite.xml</suiteXmlFile>
</suiteXmlFiles>
<dependenciesToScan>
<dependency>${test.library.groupId}:${test.library.artifactId}</dependency>
</dependenciesToScan>
</configuration>
</plugin>
会发生什么:
- 集成测试按预期运行,
- 构建失败,因为它找不到任何要运行的测试(在验证阶段!? - 见下文),并且
- 当我删除 failIfNoTests 时,即使有测试失败,也会报告构建成功
我检查了各种各样的东西,并尝试了一些东西,所以我不确定我可能在这里遗漏了什么。如果我不使用 dependenciesToScan,插件配置显然可以正常工作。
当您使用 dependenciesToScan 时,故障安全插件中是否存在破坏验证业务逻辑的错误?
Tests run: 79, Failures: 6, Errors: 0, Skipped: 0
[INFO]
[INFO] --- maven-failsafe-plugin:2.18.1:verify (default) @ test-runner ---
[DEBUG] Configuring mojo org.apache.maven.plugins:maven-failsafe-plugin:2.18.1:verify from plugin realm ClassRealm[plugin>org.apache.maven.plugins:maven-failsafe-plugin:2.18.1, parent: sun.misc.Launcher$AppClassLoader@42a57993]
[DEBUG] Configuring mojo 'org.apache.maven.plugins:maven-failsafe-plugin:2.18.1:verify' with basic configurator -->
[DEBUG] (s) basedir = /xyz/test-runner
[DEBUG] (f) encoding = UTF-8
[DEBUG] (s) failIfNoTests = true
[DEBUG] (s) reportsDirectory = /xyz/test-runner/target/failsafe-reports
[DEBUG] (s) skip = false
[DEBUG] (f) summaryFile = /xyz/test-runner/target/failsafe-reports/failsafe-summary.xml
[DEBUG] (s) testClassesDirectory = /xyz/test-runner/target/test-classes
[DEBUG] (s) testFailureIgnore = false
[DEBUG] -- end configuration --
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 03:27 min
[INFO] Finished at: 2015-03-13T22:44:46-04:00
[INFO] Final Memory: 13M/250M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-failsafe-plugin:2.18.1:verify (default) on project test-runner: No tests to run! -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-failsafe-plugin:2.18.1:verify (default) on project test-runner: No tests to run!
【问题讨论】:
标签: java maven maven-failsafe-plugin