对Cucumber-JVM 4.0的Extentreport支持(io.cucumber)

时间:2019-04-19 14:25:09

标签: maven cucumber cucumber-java

我正在尝试将黄瓜自动化项目从黄瓜(info.cukes)迁移到黄瓜(io.cucumber)

在此过程中,我无法迁移扩展报告。您能帮我解决我所缺少的吗?

依赖性:

    <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>3.8.1</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>cucumber-java</artifactId>
            <version>4.2.6</version>
            <scope>test</scope>
        </dependency>
        <!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-junit -->
        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>cucumber-junit</artifactId>
            <version>4.2.6</version>
            <scope>test</scope>
        </dependency>
        <!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-core -->
        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>cucumber-core</artifactId>
            <version>4.2.6</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-html -->
        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>cucumber-html</artifactId>
            <version>0.2.7</version>
        </dependency>
<dependency>
            <groupId>org.freemarker</groupId>
            <artifactId>freemarker</artifactId>
            <version>2.3.26-incubating</version>
        </dependency>


        <dependency>
            <groupId>com.vimalselvam</groupId>
            <artifactId>cucumber-extentsreport</artifactId>
            <version>3.0.2</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/com.aventstack/extentreports -->
        <dependency>
            <groupId>com.aventstack</groupId>
            <artifactId>extentreports</artifactId>
            <version>4.0.9</version>
        </dependency>

亚军类:

package CucumberWithAfterStep.AfterStepPOC;
import java.io.File;
import org.junit.AfterClass;
import org.junit.runner.RunWith;
import com.cucumber.listener.Reporter;
import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;

@RunWith(Cucumber.class)
@CucumberOptions(features = "src/test/resources/features", glue = { "testSteps" }, plugin = { "pretty",
                                "html:target/cucumber", "json:target/cucumber.json" , "com.cucumber.listener.ExtentCucumberFormatter:target/cucumber-reports/report.html" },
                                monochrome = true, 
                                tags = {"@WAC003 "}, dryRun = false)

public class MainRunnerTest {

 @AfterClass
 public static void writeExtentReport() {
     Reporter.loadXMLConfig(new File(FileReaderManager.getInstance().getConfigReader().getReportConfigPath()));
    }
 }

错误:

cucumber.runtime.CucumberException: Couldn't load plugin class: com.cucumber.listener.ExtentCucumberFormatter. It does not implement
     

cucumber.api.Plugin         在Cucumber.runtime.formatter.PluginFactory.loadClass(PluginFactory.java:176)         在Cucumber.runtime.formatter.PluginFactory.pluginClass(PluginFactory.java:163)         在黄瓜。运行时。格式器.PluginFactory.getPluginClass(PluginFactory.java:220)         在Cucumber.runtime.formatter.PluginFactory.isStepDefinitionReporterName(PluginFactory.java:203)         在Cucumber.runtime.RuntimeOptions $ ParsedPluginData.addPluginName(RuntimeOptions.java:386)         在Cucumber.runtime.RuntimeOptions.parse(RuntimeOptions.java:165)         在Cucumber.runtime.RuntimeOptions。(RuntimeOptions.java:108)

2 个答案:

答案 0 :(得分:1)

在黄瓜中实现范围报告有两种方法

1。将Cucumber-JVM 4适配器用于Extent Framework(extentreports-cucumber4-adapter) &以下是实现-

的步骤

在POM.XML下添加适配器依赖项

<dependency>
    <groupId>com.aventstack</groupId>
    <artifactId>extentreports-cucumber4-adapter</artifactId>
    <version>1.0.6</version>
</dependency>

将com.aventstack.extentreports.cucumber.adapter.ExtentCucumberAdapter插件添加到运行器中。

@RunWith(Cucumber.class)
@CucumberOptions(plugin = {"com.aventstack.extentreports.cucumber.adapter.ExtentCucumberAdapter:"})
public class RunCukesTest {
    // ..
} 

报告输出目录-../项目目录/ test-output / HtmlReport

2。在POM.XML

下添加aventstack依赖项
<dependency>
    <groupId>com.aventstack</groupId>
    <artifactId>extentreports</artifactId>
    <version>3.1.5</version>
</dependency> 

在此工作流程中,请勿将com.aventstack.extentreports.cucumber.adapter.ExtentCucumberAdapter插件添加到运行器。

答案 1 :(得分:0)

我有同样的问题。您可以使用以下依赖项组合, 黄瓜芯4.2.0 黄瓜Java 4.2.0 黄瓜junit 4.2.0 scopereports-cucumber4-adapter 1.0.7

请注意,vimalselvam开发的Cucumber-extntsreport不支持黄瓜版本4。因为黄瓜4使用的是基于事件的报告,而不是格式化程序。 因此删除此依赖项。 黄瓜extentsreport 3.0.2