我有一个由两部分组成的REST保证测试,并且正在尝试寻找一种写法,如果第一部分找不到所需的内容,那么第二部分将不会运行并且该测试不会失败。
测试概述-
我正在尝试编写测试,以便如果part1找不到状态为已提交的任何帐户,则该测试将不会运行或失败。
这是我到目前为止所拥有的:
// THIS TEST CASE VERIFIES THAT YOU CAN VALIDATE A NEW ADD EXTERNAL ACCOUNT REQUEST - HAPPY PATH
@Test
public void testValidateExternalAccount() throws IOException
{
BigDecimal transactionAmountOne = new BigDecimal (9);
BigDecimal transactionAmountTwo = new BigDecimal (10);
//PART1: EXTRACTS THE ACCOUNTID FROM THE ACCOUNT WITH THE SUBMITTED STATUS
String accountid = given().
spec(requestSpec).
pathParam("CustId", VALID_CUST_ID).
contentType("application/json;charset=utf-8").log().all().get("/external-accounts/{CustId}").then().extract().
path("externalAccountsDetails.find{it.status== 'SUBMITTED'}.accountId");
System.out.println(accountid);
//PART2: POSTS THE VALIDATE API FOR THE SUBMITTED STATUS ACCOUNT FROM PART1
Response response = given().
contentType("application/json;charset=utf-8").
spec(requestSpec).
pathParam("accountid", accountid).
body(validateExternalAccount(transactionAmountOne, transactionAmountTwo)).
when().
post("/external-accounts/validation/{accountid}").
then().
assertThat().statusCode(200).
and().
extract().
response();
//for prefix to find in build logs
System.out.println("testValidateExternalAccount test prefix to find in console"+response.getBody().asString());
}
任何帮助将不胜感激!
谢谢