黄瓜和junit在jenkins中有错误的测试数量(surefire)

问题描述 投票:4回答:3

当我尝试通过Maven(surefire)一起使用Cucumber和Junit时,报告的测试数量错误。我只有250次测试,但Jenkins给我看了1200次测试。因此,当我调查它时,我发现只有一个引用是surefire插件的问题。

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

怎么纠正呢?

maven junit jenkins cucumber surefire
3个回答
1
投票

我只能用万无一失创造黑客。如果你愿意,你可以使用:

  1. 有必要将Cucumber的junit报告创建到某个文件夹(1)'cucumber'
  2. 将surefire报告(不包括由surefire生成的黄瓜报告)复制到某个文件夹(2)'surefire-reports-fixed',其中黄瓜生成报告。
  3. 从(1)到(2)复制黄瓜junit报告
  4. 詹金斯必须使用文件夹(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'


0
投票

以下链接似乎是相关的。

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

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

单独的问题,在评论中讨论了将计数步骤作为测试更改为计数方案作为junit测试的修正将即将出现,但与Gherkin 3开发工作有关:

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


0
投票

以下工作对我来说 - 我在@cucumbeOptions中添加了cucumber-junit报告格式,即 - “junit:target / surefire-reports / TEST-TestSuite.xml”,接下来当我在eclipse中运行它时(也在VSO中),Junit报告是在TEST-TestSuite.xml文件中生成的,并且具有正确的计数。

代码如下 - >

    @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
           )
© www.soinside.com 2019 - 2024. All rights reserved.