W3Cschool
恭喜您成為首批注冊用戶
獲得88經(jīng)驗值獎勵
由于您正在開發(fā)存根,因此需要確保它實際上類似于您的具體實現(xiàn)。您不能存在存根以一種方式運行而應(yīng)用程序以不同方式運行的情況,尤其是在生產(chǎn)環(huán)境中。
為了確保您的應(yīng)用程序符合您在存根中定義的方式,將從提供的存根中生成測試。
自動生成的測試或多或少看起來像這樣:
@Test public void validate_shouldMarkClientAsFraud() throws Exception { // given: MockMvcRequestSpecification request = given() .header("Content-Type", "application/vnd.fraud.v1+json") .body("{\"client.id\":\"1234567890\",\"loanAmount\":99999}"); // when: ResponseOptions response = given().spec(request) .put("/fraudcheck"); // then: assertThat(response.statusCode()).isEqualTo(200); assertThat(response.header("Content-Type")).matches("application/vnd.fraud.v1.json.*"); // and: DocumentContext parsedJson = JsonPath.parse(response.getBody().asString()); assertThatJson(parsedJson).field("['fraudCheckStatus']").matches("[A-Z]{5}"); assertThatJson(parsedJson).field("['rejection.reason']").isEqualTo("Amount too high"); }
Copyright©2021 w3cschool編程獅|閩ICP備15016281號-3|閩公網(wǎng)安備35020302033924號
違法和不良信息舉報電話:173-0602-2364|舉報郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號
聯(lián)系方式:
更多建議: