JUnit testing got initializationError with java.lang.Exception: No tests found matching
After googled some answers. I found there's an issue talked about this case as below:
https://github.com/junit-team/junit4/issues/1277 (FilterRequest may hide the real failure cause(exception) of a test)
Here're the steps I tried:
1. don't select the testing function alone, while select "Run all the tests in the selected project" option on the Test Tab, when select the Junit project name
after click on Run->"Run(Debug) Configuration"
2. You can get the details of the error as follows:
initializationError(com.company.product.api.web.rest.HostControllerTest)
java.lang.Exception: Method testSetDBConfiguration should have no parameters
at org.junit.runners.model.FrameworkMethod.validatePublicVoidNoArg(FrameworkMethod.java:76)
at org.junit.runners.ParentRunner.validatePublicVoidNoArgMethods(ParentRunner.java:155)
3.according to the details given by eclipse above, I removed the argument of that function, the initializedError just disappeared.
So this issue rises due to the new added testing function has unnecessary input argument. The incorrect code :
@Test
public void testSetDBConfiguration(String name) throws Exception {
Changed to
@Test
public void testSetDBConfiguration() throws Exception {
Had the same issue with PowerMock @RunWith(PowerMockRunner.class)
then discovered that my @Test
was the wrong implementation. Was using
import org.junit.jupiter.api.Test
;
I switched to import org.junit.Test;
and that fixed the problem for me.