我在一个功能文件中有 4 个测试,有 2 个不同的标签 @first 和 @then。我希望 @first 测试首先以并行性运行,@then 测试在所有 @first 测试完成后运行,同时也具有并行性。
项目在这里: https ://github.com/marcesso/qafTesting
@CucumberOptions(plugin = {"com.qmetry.qaf.automation.cucumber.QAFCucumberPlugin", "pretty", "html:target"},
/*tags = {"@Ignore"},*/
features = {"src/test/resources/my/custom/packagename/testing"})
public class RunnerTest extends AbstractTestNGCucumberTests {
@Autowired
private ObjectMapper objectMapper;
@Test(description = "Runs Cucumber Scenarios", dataProvider = "scenarios", groups = {"first"})
public void runScenarioFirst(PickleWrapper pickleWrapper, FeatureWrapper featureWrapper) throws Throwable {
super.runScenario(pickleWrapper,featureWrapper);
}
@Test(description = "Runs Cucumber Scenarios", dataProvider = "scenarios", groups = {"then"}, dependsOnMethods =
"runScenarioFirst")
public void runScenarioThen(PickleWrapper pickleWrapper, FeatureWrapper featureWrapper) throws Throwable {
super.runScenario(pickleWrapper,featureWrapper);
}
@Override
@DataProvider(name = "scenarios", parallel = true)
public Object[][] scenarios() {
return super.scenarios();
}
@PostConstruct
public void setUp() {
objectMapper.registerModule(new JavaTimeModule());
}
}
问题是所有测试都运行两次(每个测试方法一次),@Test 注释的“组”属性没有像我预期的那样过滤测试(在https://qmetry.github.io/qaf/latest/gherkin_client非常底部.html )
也根本没有并行性。
我试图在测试方法中过滤泡菜,但与条件不匹配的测试即使没有运行也会显示为通过
if(pickleWrapper.getPickle().getTags().contains("@first")) {
super.runScenario(pickleWrapper,featureWrapper);
}