(亲测解决)JUnit测试提示Java.lang.Exception: No runnable methods

版权声明:本文为博主原创文章,转载请注明出处! https://blog.csdn.net/sinat_34104446/article/details/82781936

一、问题描述

1.使用spring-test的JUnit测试提示Java.lang.Exception: No runnable methods,代码没有问题,但是就是报这个错误

2.造成这个问题的原因有两个,没有在方法上指定@Test@Test的包导错了

二、问题解决

1.没有在方法上加入@Test,导致错误

2.@Test导入的包错了,spring-test需要的Junit是org.junit.Test,但是在@Test有两个包,另一个是org.junit.jupiter.api.Test,如果将org.junit.Test导错成了org.junit.jupiter.api.Test就会报这个错误,改正包之后问题解决

3.提示:如果只是普通的测试,没有用spring-test,name上面@Test导入哪个包的都可以

猜你喜欢

转载自blog.csdn.net/sinat_34104446/article/details/82781936