【SpringBoot】单元测试

@RunWith(SpringRunner.class)
@SpringBootTest(classes = Application.class,webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)

public class TestUserController {
    @Autowired
    private TestRestTemplate restTemplate;
    @Test
    public void get() throws Exception {
        MultiValueMap<String, Object> map = new LinkedMultiValueMap<>();
        map.add("phone", "xxx");
        String result = restTemplate.postForObject("/my/sendCode", map, String.class);
        System.out.println(result);
    }
}
posted @ 2018-04-19 20:27  SEC.VIP_网络安全服务  阅读(91)  评论(0编辑  收藏  举报