Scenario Outline: Negative scenario, create user should be fail if field miss in body When call REST API to create user and field miss <fieldName> in body Then user should create failure, err msg contains <fieldInMsg> show in response Examples: | fieldName | fieldInMsg | | provisionerId | Provisioner ID | | provisionerName | Provisioner name | | provisionerPassword | Provisioner password | | provisionerEmail | Provisioner email |
对应的 Java 代码
1 2 3 4 5 6 7 8 9 10 11 12 13
publicclassCreateUserImpl{
@When("call REST API to create user and field miss {} in body") publicvoidcallRESTAPIToCreateProvisionerAndFieldMissFieldNameInBody(String fieldName){ System.out.println("fileName: " + fieldName); }
@Then("user should create failure, err msg contains {} show in response") publicvoidprovisionerShouldCreateFailureErrMsgContainsFieldInMsgShowInResponse(String fieldInMsg){ String errMsg = fieldInMsg + "can not be null."; System.out.println(errMsg); } }
Scenario: Show my fruits When I have kinds of fruits | Apple | | Banana | Then show them
java 实现代码
1 2 3 4 5 6 7 8 9
@When("I have kinds of fruits") publicvoidiHaveKindsOfFruits(DataTable dataTable){ List<String> list = dataTable.asList(); System.out.println(Arrays.toString(list.toArray())); }