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



我正在尝试自定义范围报告,这是一个第三方报告工具,添加到我的黄瓜框架中,我想在其中自定义报告的名称.html到"输出文件名".html我无法做到,因为"输出文件名"的值来自我的配置文件。

这是我的测试运行程序代码

@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();

我真的很感激你的帮助。

最后我修复了它-

所以基本上我们需要像这样改变运行器类——

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");
}

最新更新