springboot 的测试头

好记忆不如烂笔头,能记下点东西,就记下点,有时间拿出来看看,也会发觉不一样的感受.
 

UT 测试是在开发中经常用到的,但是究竟用哪一种,这个还要根据具体的业务来确定。

方式一、 api方式
    @RunWith(SpringRunner.class)
    @SpringBootTest


方式二、 api方式
    @RunWith(SpringRunner.class)
    @SpringBootTest(classes=XxxApplication.class)


方式三、 Web程序的
    @RunWith(SpringRunner.class)
    @SpringBootTest(classes = XxxApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
 

基本上都使用如上这几种方式来操作。

猜你喜欢

转载自blog.csdn.net/supingemail/article/details/109506276
今日推荐