junit报错:No tests found matching [{ExactMatcher:fDisplayName=

写SpringCloud项目使用junit测试rabbitmq发送消息时,运行junit测试方法报错:

java.lang.Exception: No tests found matching [{ExactMatcher:fDisplayName=sendMsg_directExch], {ExactMatcher:fDisplayName=sendMsg_directExch(com.blu.ExchangeTest)], {LeadingIdentifierMatcher:fClassName=com.blu.ExchangeTest,fLeadingIdentifier=sendMsg_directExch]] from org.junit.internal.requests.ClassRequest@c46bcd4

在网上查找原因,排除了没加@Test注解,测试方法不是用public void修饰等原因。

后来发现自己的测试类所在的包名和springboot启动类所在的包名不一致,将包名修改为一致后,该报错消失,问题解决。

发布了20 篇原创文章 · 获赞 3 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/BLU_111/article/details/105500534