I am facing one problem while running the Junit scripts. I am getting the below error message.
I have three java classes under which i have commented all the @Test annotations from Class A and Class B but have four @Test annotations in Class C..but still it is showing the below error message.
Can anyone help me how to fix this issue?
Error: java.lang.Exception: No runnable methods
at org.junit.runners.BlockJUnit4ClassRunner.validateInstanceMethods(BlockJUnit4ClassRunner.java:169)
at org.junit.runners.BlockJUnit4ClassRunner.collectInitializationErrors(BlockJUnit4ClassRunner.java:104)
at org.junit.runners.ParentRunner.validate(ParentRunner.java:355)
at org.junit.runners.ParentRunner.<init>(ParentRunner.java:76)
at org.junit.runners.BlockJUnit4ClassRunner.<init>(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.Parameterized$TestClassRunnerForParameters.<init>(Parameterized.java:171)
at org.junit.runners.Parameterized.createRunnersForParameters(Parameterized.java:319)
at org.junit.runners.Parameterized.<init>(Parameterized.java:282)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
Can anyone please help here?
Ensure that all of your relevant test case objects are public
and non-abstract
, and that your test methods are annotated with @Test
but are also public void
and non-static
.
See more at the JUnit Getting Started Guide.
Make sure you have this import:
import org.junit.Test;
instead of:
import org.junit.jupiter.api.Test;
As well as the following annotations on test class if your project is SpringBoot 2:
@SpringBootTest
@RunWith(SpringRunner.class)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With