如何执行相同的黄瓜功能或场景n次? [英] How to execute same cucumber feature or scenario n times?
问题描述
我需要执行一种情况,该情况是一项功能的一部分,需要执行100次.没有方案大纲,因为没有数据参数化.我只需要在此特定情况下执行大猩猩测试,以确保它每次通过都可以成功.我的一些团队成员几次观察到失败,因此需要验证稳定性.
I need to execute one scenario which is part of one feature 100 times. There is no scenario outline as there is no data parameterization. I just need to perform gorilla testing on this particular scenario so as to make sure it passes every single time without any fail. Some of my team members observed failure a couple of times, so need to validate the stability.
Runner类代码:
Runner class code:
public class Baserunner extends AbstractTestNGCucumberTests{
private TestNGCucumberRunner testNGCucumberRunner;
@BeforeClass(alwaysRun = true)
public void setUpClass() throws Exception {
System.out.println("Test");
String browsername = "IExplorer";
testNGCucumberRunner = new TestNGCucumberRunner(this.getClass());
BaseConfig.ConfigFileReader();
BaseConfig.launchbrowser(browsername);
// BaseConfig.executeScript();
}
@Test(groups = "cucumber", description = "Runs Cucumber Feature", dataProvider = "features")
public void feature(CucumberFeatureWrapper cucumberFeature) {
testNGCucumberRunner.runCucumber(cucumberFeature.getCucumberFeature());
}
@DataProvider
public Object[][] features() {
return testNGCucumberRunner.provideFeatures();
}
@AfterClass(alwaysRun = true)
public void tearDownClass() throws Exception {
testNGCucumberRunner.finish();
BaseConfig.closeBrowser();
}
推荐答案
您可以在运行程序类中使用循环逻辑在hack之下尝试使用此方法.
You could try this below hack with a looping logic in the runner class.
@Override
@Test(groups = "cucumber", description = "Runs Cucumber Feature", dataProvider = "features")
public void feature(CucumberFeatureWrapper cucumberFeature) {
for(int i=0;i<100;i++)
testNGCucumberRunner.runCucumber(cucumberFeature.getCucumberFeature());
}
另外,您必须通过指定行号来确保仅执行一种方案.
Plus you have to make sure only one scenario is executed by specifying the line number.
@CucumberOptions(features = {"src/test/resources/stepdef/scenarios.feature:3"})
您正在使用哪个版本的黄瓜?
What version of cucumber are you using?
这篇关于如何执行相同的黄瓜功能或场景n次?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!