1.注解列表
@RunWith(SpringRunner.class) @SpringBootTest(classes = {Application.class})
2.Assert断言
3.Web模拟测试
@RunWith(SpringRunner.class) @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) public class TestServiceImplTest { @Autowired private TestRestTemplate restTemplate; @Test public void test() { restTemplate.getForObject(xx, xx) } }
4.数据库测试
给测试类上添加“@Transactional”,这样既可以测试数据操作方法,又不会污染数据库了。
https://www.cnblogs.com/vipstone/p/9908545.html
JUnit基本注解使用
https://www.jianshu.com/p/921282034c5d
https://blog.csdn.net/qq_42651904/article/details/89945495
原文:https://www.cnblogs.com/foolash/p/12131940.html