当我尝试通过Maven(surefire)同时使用Cucumber和Junit时,报告显示的测试数量不正确。我只有250个测试,但Jenkins却显示了1200个测试。因此,当我进行调查时,我只能找到一个参考,即surefire插件存在问题。
如何更正它?
我只能使用surefire创建hack。如果你喜欢,可以使用以下方法:
Maven中的示例更改:
<plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<id>change-bad-cucumber-test-file</id>
<!-- here the phase you need -->
<phase>prepare-package</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${basedir}/target/surefire-reports-fixed</outputDirectory>
<resources>
<resource>
<directory>${basedir}/target/cucumber</directory>
</resource>
<resource>
<directory>${basedir}/target/surefire-reports</directory>
<excludes>
<exclude>**/*CucumberTest.*</exclude>
</excludes>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
CucumberTest.java的更改:
@RunWith(Cucumber.class)
@Cucumber.Options(format = { "pretty", "junit:target/cucumber/TEST-packageHereToClass.CucumberTest.xml", "json:target/cucumber.json" })
public class CucumberTest {
...
}
在 Jenkins 中设置测试的 surefire 文件夹为 (2) 'surefire-reports-fixed'
@CucumberOptions(
features= {"src/test/resources/Features"},
plugin = {"pretty:STDOUT","html:Reports/cucumber-pretty","junit:target/surefire-reports/TEST-TestSuite.xml", "com.cucumber.listener.ExtentCucumberFormatter:Reports/Reporting/Quixxi_Report.html"},
monochrome = true,
dryRun=false
)
以下链接似乎与此相关。
讨论步骤定义作为测试的核心问题:
https://github.com/cucumber/cucumber-jvm/issues/577
关于另一个问题,在评论中讨论了从计算步骤到计算场景作为 JUnit 测试的更改修复将会推出,但与 Gherkin 3 开发工作相关联: