如何使用System.setProperty设置@CucumberOptions

时间:2019-05-08 13:56:42

标签: java cucumber testng

我正在使用testNG来执行Cucumber测试。我想使用来自配置文件的自定义值覆盖@CucumberOptions。如何在TestNG中设置@CucumberOptions?

下面的代码不起作用,使用@CucumberOptions值。

@CucumberOptions(features = { "src/test/resources/features/" }, tags = { "@Test3" }, glue = { "stepdefinitions" }, plugin = { "listeners.ExtentCucumberFormatter:" })
public class TestNGRunner extends AbstractTestNGCucumberTests {

private static Logger Log = Logger.getLogger(Log.class.getName());
private static String hostname = "Unknown";
private TestNGCucumberRunner tcr;
private String featureName;

@BeforeClass(alwaysRun = true)
public void beforeClass() throws Exception {
    ExtentProperties extentProperties = ExtentProperties.INSTANCE;
    File theDir = new File(GetPath.getLocalReport() + "\\" + listeners.Reporter.getReportDir());
    if (!theDir.exists()) {
        Log.info("Creating test automation report directory " + theDir.getName());
        boolean result = false;
        try {
            theDir.mkdir();
            result = true;
        } catch (SecurityException se) {
            Log.severe("Write permission denied.");
        }
        if (result) {
            Log.info("The directory was created successfully.");
        }
    }
    extentProperties.setReportPath(listeners.Reporter.getReportFullPath());
    System.setProperty("cucumber.options", "--tags @TestERROR");
    tcr = new TestNGCucumberRunner(this.getClass());
    }
    }
}

0 个答案:

没有答案