package com.bosch.runner;
import com.aventstack.extentreports.ResourceCDN;
import com.aventstack.extentreports.reporter.ExtentHtmlReporter;
import com.cucumber.listener.Reporter;
import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.runner.RunWith;
import java.io.File;
@RunWith(Cucumber.class)
@CucumberOptions(features = "src/test/resource/feature",
plugin = {
"com.cucumber.listener.ExtentCucumberFormatter:target/cucumber-reports/report.html",
"json:target/cucumber-reports/cucumber.json",
"pretty",
"html:target/html-report/cucumber-html-reports.html",
"junit:target/cucumber-reports/cucumber.xml" },
glue = {"com.bosch.step_definitions"},
tags = {})
public class RunCucumberTest {
@BeforeClass
public static void setup() {
ExtentHtmlReporter htmlReporter = new ExtentHtmlReporter("target/extent-report/extend/report.html");
htmlReporter.config().setResourceCDN(ResourceCDN.EXTENTREPORTS);
}
@AfterClass
public static void writeExtentReport() {
Reporter.loadXMLConfig(new File("src/test/resource/config/extent-config.xml"));//
Reporter.setSystemInfo("user", System.getProperty("user.name"));
Reporter.setSystemInfo("os", "Windows");
Reporter.setTestRunnerOutput("Sample test runner output message");
}
}
java cucumber maven-Runner 文件
最新推荐文章于 2024-09-25 10:59:43 发布
该代码片段展示了如何在Java项目中配置Cucumber测试框架,结合ExtentReports生成详细的测试报告。@BeforeClass和@AfterClass注解用于设置测试环境,包括HTML报告的生成和系统信息的记录。CucumberOptions定义了测试特性文件的位置、插件(如JSON和HTML报告)、Glue路径以及测试标签。
摘要由CSDN通过智能技术生成