java.lang.Exception: Method a() should be public

发布时间:2023年12月19日

场景:在使用spring boot测试接口时报错

原因:调用了错误的方法

报错:

java.lang.Exception: Method a() should be public

?? ?at org.junit.runners.model.FrameworkMethod.validatePublicVoid(FrameworkMethod.java:96)
?? ?at org.junit.runners.model.FrameworkMethod.validatePublicVoidNoArg(FrameworkMethod.java:74)
?? ?at org.junit.runners.ParentRunner.validatePublicVoidNoArgMethods(ParentRunner.java:155)
?? ?at org.junit.runners.BlockJUnit4ClassRunner.validateTestMethods(BlockJUnit4ClassRunner.java:208)
?? ?at org.junit.runners.BlockJUnit4ClassRunner.validateInstanceMethods(BlockJUnit4ClassRunner.java:188)
?? ?at org.junit.runners.BlockJUnit4ClassRunner.collectInitializationErrors(BlockJUnit4ClassRunner.java:128)
?? ?at org.junit.runners.ParentRunner.validate(ParentRunner.java:416)
?? ?at org.junit.runners.ParentRunner.<init>(ParentRunner.java:84)
?? ?at org.junit.runners.BlockJUnit4ClassRunner.<init>(BlockJUnit4ClassRunner.java:65)
?? ?at org.junit.internal.builders.JUnit4Builder.runnerForClass(JUnit4Builder.java:10)
?? ?at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
?? ?at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:26)
?? ?at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
?? ?at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:33)
?? ?at org.junit.internal.requests.FilterRequest.getRunner(FilterRequest.java:36)
?? ?at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:50)
?? ?at com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute(IdeaTestRunner.java:38)
?? ?at com.intellij.rt.execution.junit.TestsRepeater.repeat(TestsRepeater.java:11)
?? ?at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:35)
?? ?at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:235)
?? ?at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:54)

文章来源:https://blog.csdn.net/qq_48817343/article/details/135088303
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。