【问题标题】:cucumber and junit have wrong amount of tests in jenkins (surefire)cucumber 和 junit 在 jenkins 中的测试数量错误(surefire)
【发布时间】:2012-10-31 17:40:06
【问题描述】:

当我尝试通过 Maven (surefire) 一起使用 Cucumber 和 Junit 时,报告的测试数量错误。我只有 250 个测试,但 Jenkins 向我展示了 1200 个测试。所以当我调查它时,我只能找到一个参考,那就是肯定插件的问题。

https://github.com/cucumber/cucumber-jvm/issues/322

如何纠正?

【问题讨论】:

    标签: maven junit jenkins cucumber surefire


    【解决方案1】:

    我只能用万无一失来创建黑客。如果你喜欢,你可以使用:

    1. 需要通过 Cucumber 创建 junit 报告到某个文件夹 (1) 'cucumber'
    2. 将surefire报告(不包括由surefire生成的Cucumber报告)复制到cucumber生成报告的某个文件夹(2)“surefire-reports-fixed”。
    3. 将黄瓜 junit-report 从 (1) 复制到 (2)
    4. jenkins 必须使用文件夹 (2) 'surefire-reports-fixed'

    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'

    【讨论】:

      【解决方案2】:

      以下链接似乎是相关的。

      关于步骤定义算作测试的核心问题的讨论:

      https://github.com/cucumber/cucumber-jvm/issues/577

      单独的问题,在 cmets 中讨论了从将步骤计数为测试更改为将场景计数为 junit 测试的修复程序即将发布,但与 Gherkin 3 开发工作相关:

      https://github.com/cucumber/cucumber-jvm/issues/263

      【讨论】:

      • 我可以理解没有人关心它。对我来说,它使用 maven-surefire-plugin 用于 2.12 版本,而上述工作流程没有任何变化,但它出现在新版本的surefire插件中(2.18.1 再次不起作用)。
      • maven-surefire-plugin for 2.12 仅与 junit 并行工作。 2.18.1 与 testng 一起使用没有问题。
      【解决方案3】:

      以下内容对我有用- 我在@cucumbeOptions ie - "junit:target/surefire-reports/TEST-TestSuite.xml" 中添加了 cucumber-junit 报告格式,然后当我在 eclipse(也在 VSO 中)运行它时,在 TEST-TestSuite.xml 文件中生成了具有正确计数的 Junit 报告。

      代码如下-->

          @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
                 )
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2016-01-04
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2020-12-27
        相关资源
        最近更新 更多