因为项目有时候会用到 所以去网上找了这些 写了个暂时够用的比较简单的 网上资料还是蛮多的 有空可以继续深入一下
调用service接口测试流程:
- 继承TestUtil类
- 使用@Test(org.junit.Test)注解测试方法
- 选中方法名点击右键 ----> 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 {
}