Spring boot 单元测试

来源:互联网 发布:软件专利 实用新型 编辑:程序博客网 时间:2024/05/19 20:41

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 org.junit.Test;import com.lgsc.cjbd.BookApplication;@RunWith(SpringJUnit4ClassRunner.class)@WebAppConfiguration@SpringBootTest(classes = BookApplication.class, webEnvironment = SpringBootTest.WebEnvironment.MOCK)public class MyTest {@Testpublic void testGreen(){}}


注意:类名千万别取 Test ,别问我为什么 T_T -> 狗血错误


原创粉丝点击