qaf 2.1.13中无法解析要素文件中的元数据标签

问题描述 投票:0回答:1
  1. config.xml中

  1. providerclass: public class CustomDataProdvider { @DataProvider(name="my-custom-dp") public static Object[][] dataProviderForBDD(){ Map<Object, Object> rec1 = Maps.newHashMap(); rec1.put("fruit", "grapes"); rec1.put("color", "green"); Map<Object, Object> rec2 = Maps.newHashMap(); rec2.put("fruit", "banana"); rec2.put("color", "yellow"); return new Object[][]{ {rec1},{rec2}}; }
  2. 特征: @TestForTest SCENARIO : Custom Data provider Example META-DATA: {"dataProvider":"my-custom-dp", "dataProviderClass":"com.qmetry.qaf.example.CustomDataProvider", "description":"Data driven test that uses custom data provider"} Given I am on fruits and colors activity When i select '${fruit}' Then the color should be '${color}' END
  3. 脚步: @MetaData(value = "{'groups':['smoke']}") @QAFTestStepProvider public class TestDataProdivider { @QAFTestStep(description = "I am on fruits and colors activity") public void test(){ System.out.println("I am on fruits and colors activity"); } @QAFTestStep(description = "i select {fruit}") public void testfruit(String fruit){ System.out.println(fruit); } @QAFTestStep(description = "the color should be {color}") public void testcolor(String color){ System.out.println(color); } }
  4. 结果: @QAFTestStep(description="META-DATA: {0}") public void mETADATA(Map<Object,Object> mapObj0){ //TODO: remove NotYetImplementedException and call test steps throw new NotYetImplementedException(); } 测试被忽略了
testng bdd gherkin qaf
1个回答
0
投票

您正在使用GherkinScenarioFactory,它希望bdd采用小黄瓜语法。在小黄瓜Meta-data不受支持,但在qaf-bdd支持。你应该使用com.qmetry.qaf.automation.step.client.text.BDDTestFactory。您的bdd文件,比如说suite1.bdd,应该如下所示与BDDTestFactory一起使用。

SCENARIO : Custom Data provider Example
META-DATA: {"dataProvider":"my-custom-dp", "dataProviderClass":"com.qmetry.qaf.example.CustomDataProvider", "description":"Data driven test that uses custom data provider","groups":{"TestForTest","smoke"}}
   Given I am on fruits and colors activity
   When i select '${fruit}'
   Then the color should be '${color}'
END

如果你与原始进行比较,你会发现@TestForTest移动了元数据,使你的场景与qaf-bdd兼容。确保您的bdd文件具有扩展名.bdd以与BDDTestFactory一起使用。

您的配置文件应如下所示:

<suite name="QAF-Demo" verbose="0">
<test name="BDD Tests">
   <parameter name="step.provider.pkg" value="com.qmetry.qaf.example.steps" />
   <parameter name="scenario.file.loc" value="scenarios" />
   <groups>
     <run>
        <include name="TestForTest"/>
     </run>
   </groups>
   <classes>
      <class name="com.qmetry.qaf.automation.step.client.text.BDDTestFactory" />
   </classes>
</test>
</suite>

很少有观察到:

  • 您正试图通过将@MetaData(value = "{'groups':['smoke']}")放在步骤定义类中来将组添加到步骤中。这没有任何意义。应将组分配给testcase / scenario而不是步骤。
  • 此外,您不需要在步骤定义类中放置@QAFTestStepProvider,因为您使用@QAFTestStep将方法标记为步骤。

所以你的步骤定义类应该如下所示:

public class TestDataProdivider {

   @QAFTestStep(description = "I am on fruits and colors activity")
   public void test(){
      System.out.println("I am on fruits and colors activity");
   }

   @QAFTestStep(description = "i select {fruit}")
   public void testfruit(String fruit){
      System.out.println(fruit);
   }

   @QAFTestStep(description = "the color should be {color}")
   public void testcolor(String color){
      System.out.println(color);
   }
} 
© www.soinside.com 2019 - 2024. All rights reserved.