W3Cschool
恭喜您成為首批注冊(cè)用戶
獲得88經(jīng)驗(yàn)值獎(jiǎng)勵(lì)
Spring Cloud Contract生成存根,可在客戶端測(cè)試期間使用。您將獲得一個(gè)正在運(yùn)行的WireMock實(shí)例/消息傳遞路由,以模擬該服務(wù)。您想使用適當(dāng)?shù)拇娓x來(lái)提供該實(shí)例。
在某個(gè)時(shí)間點(diǎn),您需要向欺詐檢測(cè)服務(wù)發(fā)送請(qǐng)求。
ResponseEntity<FraudServiceResponse> response = restTemplate.exchange( "http://localhost:" + port + "/fraudcheck", HttpMethod.PUT, new HttpEntity<>(request, httpHeaders), FraudServiceResponse.class);
用?@AutoConfigureStubRunner
?注釋測(cè)試類。在批注中,提供Stub Runner的組ID和工件ID,以下載協(xié)作者的存根。
@RunWith(SpringRunner.class) @SpringBootTest(webEnvironment = WebEnvironment.NONE) @AutoConfigureStubRunner(ids = { "com.example:http-server-dsl:+:stubs:6565" }, stubsMode = StubRunnerProperties.StubsMode.LOCAL) public class LoanApplicationServiceTests {
之后,在測(cè)試期間,Spring Cloud Contract在Maven存儲(chǔ)庫(kù)中自動(dòng)找到存根(模擬真實(shí)服務(wù)),并將其暴露在已配置(或隨機(jī))的端口上。
Copyright©2021 w3cschool編程獅|閩ICP備15016281號(hào)-3|閩公網(wǎng)安備35020302033924號(hào)
違法和不良信息舉報(bào)電話:173-0602-2364|舉報(bào)郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號(hào)
聯(lián)系方式:
更多建議: