webClientTest 编写单元测试类

2020-08-05 15:44:47 浏览数 (1)

代码语言:javascript复制
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
@ContextConfiguration(classes = ApiServer.class)
@ActiveProfiles("dev")
public class ApiServerTest {

    @Autowired
    private WebTestClient webClient;

    @Test
    public void test_010001() throws Exception {
        Map<String, String> map = new HashMap<>();
        map.put("imei", "i1");
        BodySpec<BaseResponse, ?> i = webClient
            .get()
            .uri(uriBuilder -> uriBuilder.path("/message/testUrl")
                .queryParam("key", "30023409700").build())
            .accept(MediaType.APPLICATION_JSON_UTF8)
            .exchange()
            .expectStatus().isOk()
            .expectBody(BaseResponse.class);
    }


}
代码语言:javascript复制
<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-w

0 人点赞