spring整合junit时遇到的小问题

1)今天学习spring框架整合junit时遇到这样一个问题:

java.lang.Exception:No tests found matching [{ExactMatcher:fDisplayName=test], {ExactMatcher:fDisplayName=test(spring.SpringTest2)], {LeadingIdentifierMatcher:fClassName=spring.SpringTest2,fLeadingIdentifier=test]] from org.junit.internal.requests.ClassRequest@3eb07fd3

《spring整合junit时遇到的小问题》

2)单独运行测试方法是上面的错误,直接运行测试类,错误变成这样:

《spring整合junit时遇到的小问题》

3)通过直接运行测试类的错误发现重要的一句话:SpringJUnit4ClassRunner requires JUnit 4.12 or higher.

意思是:SpringJUnit4ClassRunner 要求junit使用4.12版本或者更高,然后去看了pom.xml,果然里面的版本是4.11,改成4.12就可以了;

4)附上测试类:

《spring整合junit时遇到的小问题》

5)仓库图:

《spring整合junit时遇到的小问题》

    原文作者:Air张
    原文地址: https://www.jianshu.com/p/b941a00e85ed
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞