编写测试用例验证服务
@SpringBootTest @RunWith(SpringRunner.class) @AutoConfigureStubRunner( ids = {"com.example:springcloud-contract-provider-rest:+:stubs:8880"}, stubsMode = StubRunnerProperties.StubsMode.LOCAL ) public class StockApiTest { @Autowired private StockApi stockApi; @Test public void testStockApi() throws IOException { StockPriceDTO stockPrice = stockApi.getStockPrice(600519).execute().body(); BDDAssertions.then(stockPrice.getId()).isEqualTo(600519); BDDAssertions.then(stockPrice.getPrice()).isEqualTo(999); } }Spring Cloud Contract 契约测试 (2)
内容版权声明:除非注明,否则皆为本站原创文章。