提供商类别:
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}};
}
功能:
@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
步骤:
@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);
}
}
结果:
@QAFTestStep(description="META-DATA: {0}")
public void mETADATA(Map<Object,Object> mapObj0){
//TODO: remove NotYetImplementedException and call test steps
throw new NotYetImplementedException();
}
测试被忽略。
答案 0 :(得分:0)
您正在使用prange
,它的黄瓜语法为bdd。在小黄瓜中,nopython=True
不支持,但qaf-bdd中支持。您应该使用GherkinScenarioFactory
。您的bdd文件(假设为suite1.bdd)应如下所示,可以与Meta-data
一起使用。
com.qmetry.qaf.automation.step.client.text.BDDTestFactory
如果与原始版本进行比较,您会发现BDDTestFactory
移入了元数据,从而使您的方案与qaf-bdd兼容。确保您的bdd文件具有扩展名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
一起使用。
您的配置文件应如下所示:
.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']}")
将方法标记为步骤。因此您的步骤定义类应如下所示:
@QAFTestStepProvider