在@CucumberOptions 中创建自定义文件报告名称

Create customize file report name in @CucumberOptions

我正在尝试自定义范围报告,这是添加到我的黄瓜框架中的第三方报告工具,我想在其中自定义 report.html 的 name 到"Outputfilename".html 我无法执行,因为 "Outputfilename " 的值来自我的配置文件。

这是我的测试代码

    @RunWith(Cucumber.class)
@CucumberOptions(
        features = ".//src//test//java//FeatureList",glue = "stepDefinations",
        plugin = { "com.cucumber.listener.ExtentCucumberFormatter:target/cucumber-reports/"+Outputfilename+".html",
                "junit:target/cucumber-results.xml"},
        tags="@smoke",
        monochrome = true
)
public class TestRunner {
    private static final String Outputfilename = FileReader.getInstance().getConfigReader().getReportPath();

非常感谢您的帮助。

终于修好了-

所以基本上我们需要改变转轮 class 像这样-

package runners;

import PageObjectRep.CF;
import com.cucumber.listener.ExtentProperties;
import com.cucumber.listener.Reporter;
import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
import managers.FileReader;
import org.apache.log4j.PropertyConfigurator;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.runner.RunWith;

import java.io.File;

@RunWith(Cucumber.class)
@CucumberOptions(
        features = ".//src//test//java//FeatureList",glue = "stepDefinations",
        plugin = { "com.cucumber.listener.ExtentCucumberFormatter:",
                "junit:target/cucumber-results.xml"},
        tags="@test",
        monochrome = true
)
public class TestRunner {
    static String ReportName= CF.ReportName(); //function which creates file name as per the execution and saved in string.
    @BeforeClass
    public static void setup() {
        ExtentProperties extentProperties = ExtentProperties.INSTANCE;
        extentProperties.setReportPath("target/cucumber-reports/"+ReportName+".html"); //used same string name to create the file with the same name.
        PropertyConfigurator.configure(".//src//log4j.properties");
    }