本文阅读量 次
1. Spring Testing¶
1.1 使用 Rest Assured 进行集成测试¶
1.1.1 使用路径参数¶
@Test
public void test_NumberOfCircuits_ShouldBe20_Parameterized() {
String season = "2017";
int numberOfRaces = 20;
given().
pathParam("raceSeason",season).
when().
get("http://ergast.com/api/f1/{raceSeason}/circuits.json").
then().
assertThat().
body("MRData.CircuitTable.Circuits.circuitId",hasSize(numberOfRaces));
}
1.2 Spring Test 中用于测试场景的注解¶
@BootstrapWith @ContextConfiguration @WebAppConfiguration @ContextHierarchy @ActiveProfiles @TestPropertySource @DynamicPropertySource @DirtiesContext @TestExecutionListeners @RecordApplicationEvents @Commit @Rollback @BeforeTransaction @AfterTransaction @Sql @SqlConfig @SqlMergeMode @SqlGroup