gpt4 book ai didi

maven - cucumber 和junit在jenkins中的测试量错误(万无一失)

转载 作者:行者123 更新时间:2023-12-01 05:27:05 30 4
gpt4 key购买 nike

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

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

如何纠正?

最佳答案

我只能用surefire来创造黑客。如果你喜欢,你可以使用:

  • 必须通过 Cucumber 创建 junit 报告到某个文件夹 (1) 'cucumber'
  • 将surefire 报告(不包括由surefire 生成的Cucumber 报告)复制到某个文件夹(2) 'surefire-reports-fixed',其中Cucumber 生成报告。
  • 将 cucumber junit-report 从 (1) 复制到 (2)
  • 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'

    关于maven - cucumber 和junit在jenkins中的测试量错误(万无一失),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13341333/

    30 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com