java cucumber maven-Runner 文件

该代码片段展示了如何在Java项目中配置Cucumber测试框架,结合ExtentReports生成详细的测试报告。@BeforeClass和@AfterClass注解用于设置测试环境,包括HTML报告的生成和系统信息的记录。CucumberOptions定义了测试特性文件的位置、插件(如JSON和HTML报告)、Glue路径以及测试标签。
摘要由CSDN通过智能技术生成
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");
    }
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值