spring-boot2.0 单元测试JUnit4

时间:2018-06-04 11:43:24   收藏:0   阅读:1502
spring-boot2.0 单元测试JUnit4

简单在spring-boot2.0版本中使用junit
源码如下:
@SpringBootTest(classes = DemoT002Application.class) 只要加上这个就能使用DemoT002Application.class是你的程序入口文件

@RunWith(SpringJUnit4Cla***unner.class) // SpringJUnit支持,由此引入Spring-Test框架支持! 
@SpringBootTest(classes = DemoT002Application.class)
public class Account_Bank_DaoTest {
    @Autowired
    private Account_Bank_Dao account_Bank_Dao;

    @Test
    public void test() throws Exception {
        String a = account_Bank_Dao.getById();
        System.out.println(a);
    }

}
评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!