记录 调用service接口进行单元测试 SpringBoot

因为项目有时候会用到 所以去网上找了这些  写了个暂时够用的比较简单的  网上资料还是蛮多的 有空可以继续深入一下

 

调用service接口测试流程:

  1. 继承TestUtil类

  1. 使用@Test(org.junit.Test)注解测试方法

  1. 选中方法名点击右键 ----> Run as ----> JUnit Test

TestUtil.java

import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.web.WebAppConfiguration;

import com.common.app.Application;

@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(classes = Application.class)
@WebAppConfiguration
public class TestUtil {
}
 

猜你喜欢

转载自blog.csdn.net/weixin_42612454/article/details/81915584
今日推荐