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
2)单独运行测试方法是上面的错误,直接运行测试类,错误变成这样:
3)通过直接运行测试类的错误发现重要的一句话:SpringJUnit4ClassRunner requires JUnit 4.12 or higher.
意思是:SpringJUnit4ClassRunner 要求junit使用4.12版本或者更高,然后去看了pom.xml,果然里面的版本是4.11,改成4.12就可以了;
4)附上测试类:
5)仓库图:
特别声明:以上内容(如有图片或视频亦包括在内)为自媒体平台“网易号”用户上传并发布,本平台仅提供信息存储服务。
Notice: The content above (including the pictures and videos if any) is uploaded and posted by a user of NetEase Hao, which is a social media platform and only provides information storage services.