Q&A-Style question as the existing questions don't match the simple typo I made here:
Goal
Problem
Code
import org.junit.jupiter.api.Test;
public class Test {
@Test
private void testAMethod() { (...) }
}
change to
public void testAMethod() { (...) }
According to Junit5 document
Test classes, test methods, and lifecycle methods are not required to be public, but they must not be private.
https://junit.org/junit5/docs/current/user-guide/
Another possibility of this error message is when using a non-void return type. Switch to void and it will work.
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