我正在BDD Framework中使用Cucumber运行脚本,并且正在使用Extent Reports插件来创建执行报告。
我已经创建了如下的测试运行器类:
import java.io.File;
import org.junit.runner.RunWith;
import org.testng.annotations.AfterClass;
import com.vimalselvam.cucumber.listener.Reporter;
import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
@RunWith(Cucumber.class)
@CucumberOptions(
features = "C:\\Users\\User\\Desktop\\Cucumber - BDD\\CucumberPOM\\src\\main\\java\\com\\qa\\features\\DemoSite.feature"//path of the feature files
,glue = {"com/qa/stepDefinitions"} //path of the step definition files
,plugin = {"com.cucumber.listener.ExtentCucumberFormatter:target/html/ExtentReport.html"}
// ,plugin = {"pretty","html:test-output","json:json_output/cucumber.json","junit:junit_output/cucumber.xml"} //to generate diff types of reporting
,monochrome =true //display the console output in a proper readable format
,strict=true //it will check if any step is not defined in step definition file
,dryRun = false //to check the mapping is proper btw feature file and step defn file
//,tags = {"@FuntionalTest" , "~@SmokeTest" , "~@End2EndTest"}
)
public class TestRunner {
@AfterClass
public static void writeExtentReport() {
Reporter.loadXMLConfig(new File("config/extent-config.xml"));
}
}
我在POM.xml文件中将以下范围报告的依赖项包括在内:
<!-- https://mvnrepository.com/artifact/com.aventstack/extentreports -->
<dependency>
<groupId>com.aventstack</groupId>
<artifactId>extentreports</artifactId>
<version>4.0.9</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.vimalselvam/cucumber-extentsreport -->
<dependency>
<groupId>com.vimalselvam</groupId>
<artifactId>cucumber-extentsreport</artifactId>
<version>3.1.1</version>
</dependency>
<dependency>
<groupId>com.aventstack</groupId>
<artifactId>extentreports-cucumber4-adapter</artifactId>
<version>1.0.7</version>
</dependency>
当我执行上述流氓类时遇到错误-cumul.runtime.CucumberException:无法加载插件类:com.cucumber.listener.ExtentCucumberFormatter
答案 0 :(得分:1)
com.vimalselvam.cucumber.listener.ExtentCucumberFormatter。如果您使用的是Cucumber 4,则必须使用Cucumber Extent Adapter作为插件。在此处查看如何在框架中使用它的详细文档-http://extentreports.com/docs/versions/4/java/cucumber4.html
答案 1 :(得分:0)
我遇到了类似的问题,为了解决这个问题,我更改了@CucumberOptions中的插件:
@CucumberOptions( 插件= {“ com.vimalselvam.cucumber.listener.ExtentCucumberFormatter:path / report.html”} )
但是,我现在仍然面临另一个问题。希望对您有帮助