Spring boot-测试类-启动报错【java.lang.Exception: No runnable methods】的解决办法

导入这个

import org.junit.jupiter.api.Test;

报错

七月 04, 2020 12:54:50 下午 org.junit.vintage.engine.descriptor.RunnerTestDescriptor warnAboutUnfilterableRunner
警告: Runner org.junit.internal.runners.ErrorReportingRunner (used on class com.nowcoder.community.CommunityApplicationTests) does not support filtering and will therefore be run completely.




org.junit.runners.model.InvalidTestClassError: Invalid test class 'com.nowcoder.community.CommunityApplicationTests':
  1. No runnable methods

	at org.junit.runners.ParentRunner.validate(ParentRunner.java:525)
	at org.junit.runners.ParentRunner.<init>(ParentRunner.java:92)
	at org.junit.runners.BlockJUnit4ClassRunner.<init>(BlockJUnit4ClassRunner.java:74)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.<init>(SpringJUnit4ClassRunner.java:137)
	at org.springframework.test.context.junit4.SpringRunner.<init>(SpringRunner.java:49)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
	at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:104)
	at org.junit.vintage.engine.discovery.DefensiveAllDefaultPossibilitiesBuilder$DefensiveAnnotatedBuilder.buildRunner(DefensiveAllDefaultPossibilitiesBuilder.java:114)
	at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:86)
	at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:70)
	at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:37)
	at org.junit.vintage.engine.discovery.DefensiveAllDefaultPossibilitiesBuilder.runnerForClass(DefensiveAllDefaultPossibilitiesBuilder.java:57)
	at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:70)
	。。。
	。。。
	。。。

导入这个

import org.junit.Test;

正确

Spring boot-测试类-启动报错【java.lang.Exception: No runnable methods】的解决办法_第1张图片

你可能感兴趣的:(java,java基础常见问题,java,junit)