从Java中的另一个类开始Cucumber runner类

问题描述 投票:3回答:1

目前,我正在尝试将黄瓜测试与硒和Java结合使用。

现在我的问题是:

是否可以从另一个类启动RunCucumber类?

到目前为止,我已经编写了这个类来从Eclipse启动Cucumber:

@RunWith(Cucumber.class)
@CucumberOptions(
    plugin = {"pretty","json:target/json/jsonoutPretty.json"},
    features={"src/main/resources/FeatureFiles"},

)
public class RunCucumber{

}

现在我想从另一个开始这个RunCucumber类。像这样的东西:

public class startTests {

    public void startRunCucumber(){

        run(RunCucumber.class);
    }

}

是否有可能实现这一目标?

谢谢!

java cucumber
1个回答
2
投票

有可能的。您可以运行用于命令行版本的Cucumber的main方法。

从你的班级调用cucumber.api.cli.Main.main()

© www.soinside.com 2019 - 2024. All rights reserved.