- 配置文件
提供者类:
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(); }
测试被忽略。