博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
springboot如何单元测试
阅读量:3919 次
发布时间:2019-05-23

本文共 1752 字,大约阅读时间需要 5 分钟。

springboot如何单元测试

pom.xml加上单元测试的依赖

org.springframework.boot
spring-boot-starter-test
test

加上一些注解点击运行就可以运行了

@RunWith(SpringRunner.class)@SpringBootTestpublic class Test {
@Autowired CategoryDAO dao; @org.junit.Test public void test(){
List
cs = dao.findAll(); for(Category c : cs){
System.out.println("Name: " + c.name); } }}

控制台显示结果

2019-11-24 11:50:22.684  INFO 7456 --- [pdateTask][T#1]] org.elasticsearch.gateway                : [Katherine Reynolds] recovered [0] indices into cluster_state2019-11-24 11:50:22.913  INFO 7456 --- [           main] com.how2java.tmall.pojo.Test             : Started Test in 8.495 seconds (JVM running for 9.327)2019-11-24 11:50:23.122  INFO 7456 --- [           main] o.h.h.i.QueryTranslatorFactoryInitiator  : HHH000397: Using ASTQueryTranslatorFactoryHibernate: select category0_.id as id1_0_, category0_.name as name2_0_ from category category0_Name: 瓦达瓦Name: 123Name: 12321Name: 1Name: 1Name: 213Name: 213Name: 312Name: 3Name: 2Name: 1Name: 45Name: 4Name: 3Name: 12Name: 312123Name: 123123Name: 12Name: 123123Name: 12Name: 12Name: 12Name: 12Name: 12Name: 12Name: 12Name: 12Name: 请问请问Name: 21Name: 66Name: 34534Name: 1111Name: 23123Name: 132312Name: 花好月圆夜2019-11-24 11:50:23.268  INFO 7456 --- [       Thread-5] o.s.w.c.s.GenericWebApplicationContext   : Closing org.springframework.web.context.support.GenericWebApplicationContext@a370f4: startup date [Sun Nov 24 11:50:14 CST 2019]; root of context hierarchy2019-11-24 11:50:23.271  INFO 7456 --- [       Thread-5] s.b.a.d.e.ElasticsearchAutoConfiguration : Closing Elasticsearch client2019-11-24 11:50:23.271  INFO 7456 --- [       Thread-5] org.elasticsearch.node

转载地址:http://duern.baihongyu.com/

你可能感兴趣的文章
Leetcode 123. 买卖股票的最佳时机 III
查看>>
Leetcode 24. 两两交换链表中的节点
查看>>
Leetcode 100. 相同的树
查看>>
Leetcode 257. 二叉树的所有路径
查看>>
Leetcode 4. 寻找两个正序数组的中位数
查看>>
Leetcode 101. 对称二叉树
查看>>
Leetcode 108. 将有序数组转换为二叉搜索树
查看>>
Leetcode 303. 区域和检索 - 数组不可变
查看>>
Leetcode 110. 平衡二叉树
查看>>
Leetcode 111. 二叉树的最小深度
查看>>
Leetcode 226. 翻转二叉树
查看>>
Leetcode 617. 合并二叉树
查看>>
Leetcode 654. 最大二叉树
查看>>
Leetcode 304. 二维区域和检索 - 矩阵不可变
查看>>
Leetcode 45. 跳跃游戏 II
查看>>
模式2. 工厂方法模式-Java
查看>>
模式1. 简单工厂模式-Java
查看>>
模式6.原型模式-Java
查看>>
Leetcode 146. LRU 缓存机制
查看>>
Leetcode 208. 实现 Trie (前缀树)
查看>>