Cucumber标记作为QAF和Spring引导环境中的TestNG组

Cucumber标记作为QAF和Spring引导环境中的TestNG组,testng,spring-test,cucumber-java,qaf,testng-annotation-test,Testng,Spring Test,Cucumber Java,Qaf,Testng Annotation Test,我在一个功能文件中有4个测试,有两个不同的标记@first和@then。 我希望@first tests首先以并行方式运行,@then tests在所有@first tests完成后以并行方式运行 项目在这里: 问题是所有测试都运行两次(每个测试方法运行一次),并且@test annotation的“groups”属性并没有像我预期的那样过滤测试(最底层) 也没有平行性 我尝试在测试方法中过滤pickle,但不符合条件的测试即使未运行也显示为通过 if(pickleWrapper.getPic

我在一个功能文件中有4个测试,有两个不同的标记@first和@then。 我希望@first tests首先以并行方式运行,@then tests在所有@first tests完成后以并行方式运行

项目在这里:

问题是所有测试都运行两次(每个测试方法运行一次),并且@test annotation的“groups”属性并没有像我预期的那样过滤测试(最底层)

也没有平行性

我尝试在测试方法中过滤pickle,但不符合条件的测试即使未运行也显示为通过

if(pickleWrapper.getPickle().getTags().contains("@first")) {
            super.runScenario(pickleWrapper,featureWrapper);
}

在上面的
RunnerTest
示例中,来自qaf的GherkinClient不会出现在图片中,因为您使用的是cucumber runner
GherkinScenarioFactory
BDDTestFactory2
(使用qaf 2.1.15+)是qaf的小黄瓜实施。当您使用它们中的任何一个时,您不需要上面的
RunnerTest
class
BDDTestFactory2
优于
GherkinScenarioFactory
,它支持标准gherkin语法之上的附加语法功能

当您使用cucumber runner(
RunnerTest
class)时,标记不被视为TestNG组。如果要使用cucumber runner运行功能文件,则需要使用cucumber选项处理它。好吧,当你使用cucumber runner时,你想要的东西是不能用一个类来实现的

当您使用qaf时,您可以使用它来代替cucumber测试类。您可以将场景作为TestNG测试用例提供xml配置。您可以混合和匹配TestNG支持的不同配置选项,就像执行用java编写的测试一样。在您的情况下,它可能如下所示:

<suite name="QAF Demo" verbose="0" parallel="false" data-provider-thread-count="10">

<test name="First"  parallel="methods"  thread-count="5">
   <groups>
      <run>
        <include name="first" />
      </run>
   </groups>
   <classes>
      <class name="com.qmetry.qaf.automation.step.client.text.BDDTestFactory2" />
   </classes>
</test>

<test name="second"  parallel="methods"  thread-count="5">
   <groups>
      <run>
        <include name="then" />
      </run>
   </groups>
   <classes>
      <class name="com.qmetry.qaf.automation.step.client.text.BDDTestFactory2" />
   </classes>
</test>
</suite>

我想在此重申,上述功能仅在使用
BDDTestFactory2
运行时可用,但在使用cucumber runner时不可用。请参阅

谢谢您的帮助,但不幸的是,我恐怕无法使用纯TestNG,因为我在测试项目的其余部分需要一些SpringBoot功能。我尝试扩展一些cucumber类以在对象[][]构建期间添加标记过滤器,但我尝试扩展的所有类都是final类,字段通常是非公共的。即使使用反射,复杂性也太高,太多的代码需要重新编写,以便于维护。我对不能扩展类感到有点失望,因为我认为这应该不会很困难,也不会很危险。别担心,springboot特性应该和cucumber runner一样工作。试试看。你可以继续使用cucumber步骤。我试过了,是的,但我在github项目中无法实现并行性,当我报告实际项目时,我发现了错误SpringBoot特性应该可以像纯TestNG一样工作。关于并行性,您需要在testng配置文件中设置线程数和并行模式。同时设置global.datadriven.parallel=truerefere是的,它工作得很好,问题是我真实项目的pom中的testng版本错误。多亏了你的建议,我可以修复并行性。谢谢
<suite name="QAF Demo" verbose="0" parallel="false" data-provider-thread-count="10">

<test name="First"  parallel="methods"  thread-count="5">
   <groups>
      <run>
        <include name="first" />
      </run>
   </groups>
   <classes>
      <class name="com.qmetry.qaf.automation.step.client.text.BDDTestFactory2" />
   </classes>
</test>

<test name="second"  parallel="methods"  thread-count="5">
   <groups>
      <run>
        <include name="then" />
      </run>
   </groups>
   <classes>
      <class name="com.qmetry.qaf.automation.step.client.text.BDDTestFactory2" />
   </classes>
</test>
</suite>
<groups>
  <run>
    <include name="first" />
  </run>
</groups>
   <parameter name="include" value="{'groups': ['first']}" />