本文共 1752 字,大约阅读时间需要 5 分钟。
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(){ Listcs = 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/