当前位置: 首页 > 知识库问答 >
问题:

如何使用Cucumber 5.6.0获取Cucumber范围报告?

朱皓
2023-03-14

我从Cucumber 1.2.5升级到Cucumber 5.6.0。升级进行得很顺利,但是我的扩展报告坏了。我尝试升级它们并使用Cucumber 4适配器。文件很稀少,我无法让它工作。所以我去下载了示例实现。我能够编译和运行它,并获得报告。我将示例项目升级到Cucumber 4.8.1,将Extent Reporter升级到4,然后运行,但没有创建报告。我不知所措,我的谷歌搜索没有找到任何信息。

下面是原始的示例项目:https://github.com/foursyth/extentreports-cucumberN-example

以下是我更新它的尝试:https://github.com/dougnoel/extentreports-cucumberN-example/tree/update_to_Cucumber4-adapter

这是pom。xml:

    <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <cucumber.version>4.8.1</cucumber.version>
</properties>
<dependencies>
    <dependency>
        <groupId>com.aventstack</groupId>
        <artifactId>extentreports-cucumber4-adapter</artifactId>
        <version>1.0.12</version>
    </dependency>
    <dependency>
        <groupId>io.cucumber</groupId>
        <artifactId>cucumber-core</artifactId>
        <version>${cucumber.version}</version>
    </dependency>
    <dependency>
        <groupId>io.cucumber</groupId>
        <artifactId>cucumber-java</artifactId>
        <version>${cucumber.version}</version>
    </dependency>
    <dependency>
        <groupId>io.cucumber</groupId>
        <artifactId>cucumber-junit</artifactId>
        <version>${cucumber.version}</version>
        <scope>test</scope>
    </dependency>
</dependencies>

这是测试跑步者:

package cucumber.examples.java.calculator;

import org.junit.runner.RunWith;

import io.cucumber.junit.CucumberOptions;
import io.cucumber.junit.Cucumber;

@RunWith(Cucumber.class)
@CucumberOptions(plugin = {"com.aventstack.extentreports.cucumber.adapter.ExtentCucumberAdapter:", "json:target/cucumber-report.json"}
, tags = { "@foo" }
)
public class RunCukesTest {

}

以下是我更新到Cucumber 5.6.0的项目,我正在努力使范围报告保持工作状态:https://github.com/dougnoel/sentinel/tree/93_update_cucumber

共有1个答案

常坚
2023-03-14

蚱蜢在评论中回答了这个问题。解决方案就是他提供的精彩指令和代码。

在pom中。我补充说:

<dependency>
    <groupId>com.aventstack</groupId>
    <artifactId>extentreports</artifactId>
    <version>4.1.5</version>
</dependency>

<dependency>
    <groupId>tech.grasshopper</groupId>
    <artifactId>extentreports-cucumber5-adapter</artifactId>
    <version>1.1.0</version>
</dependency>

在我的测试跑步者中,我提出:

package cucumber.examples.java.calculator;
import org.junit.runner.RunWith;
import io.cucumber.junit.CucumberOptions;
import io.cucumber.junit.Cucumber;

@RunWith(Cucumber.class)
@CucumberOptions(monochrome = true
    , features = "src/test/java/features"
    , glue = { "stepdefinitions", "com.dougnoel.sentinel.steps" }
    , plugin = {"com.aventstack.extentreports.cucumber.adapter.ExtentCucumberAdapter:"}

最后一部分是添加一个配置文件extent.propertiessrc/test/Resources/中,只有三行:

extent.reporter.html.start=true
extent.reporter.html.out=reports/extent-cucumber-report.html
screenshot.dir=reports/

现在一切照旧!

 类似资料:
  • 当我尝试使用Cucumber最新版本4.7.1(即“io.cucumber”)时,使用范围报告3.0不会生成报告。我尝试了不同版本的范围报告,但仍然正确生成输出。 我尝试了Cucumber和Extent Report之间的不同组合版本,但仍然没有输出。有人可以在这里发光来提高输出。 代码: 慰问: oader.java:362NoClassDefFoundError: gherkin/format

  • 我们在我的项目中使用范围报告。我想访问运行时存储的值。例如,在测试用例的catch块中,我有一行。 在最后一个块中,我试图创建一个函数,如果测试用例失败,我将需要使用日志函数的值并将其存储用于某种目的。 有可能吗?我正在POM框架中使用java和selenium。

  • 我正在从事一个基于Selenium/testng/java/gradle的项目,该项目采用了针对webdriver和extenttest对象的ThreadLocal方法。每当我的测试用例失败时,我都会使用RetryListener再次运行失败的测试用例1次。若它是第二次通过,我的结果仍然在扩展报告中显示为“失败”(注意,所有迭代都记录在html报告中的单个测试节点中)。stackoverflow对

  • 问题内容: 我试图为我在1到60之间选择的每一行生成一个随机整数作为计时器。 我已经搜索并继续使用此FLOOR函数作为如何在范围内选择随机整数。这给我每一行1。我想念什么? 我在mysql 5.0.75上 我相信这是查询的其余部分,这可能是一个嵌套问题 问题答案: 这对我有用。您的mysql版本可能是?

  • 我想展示一个IP的两个第一范围。例如,我127.0.0.1。我想得到127.0并使用这个例子: show show 我怎么能那样做? 我尝试了,但它显示了整个IP地址。

  • 我正在使用Cucumber for Java 我没有使用来配置要使用的步骤或功能。我正在使用方法 它的一切工作发现,但我想生成一个报告的结果。我正在阅读有关它的信息,要配置它,我需要使用,如下所示: 如何使用该方法配置它??