I want to create JUnit class for this code:
@Component
public class ReportingProcessor {
@EventListener
private void collectEnvironmentData() {
}
}
I tried this implement this Junit test with reflation:
public class ReportingTest {
@Test
public void reportingTest() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
Method m = ReportingProcessor.class.getDeclaredMethod("collectEnvironmentData", null);
m.setAccessible(true);
m.invoke(this);
}
}
But I get error:
java.lang.IllegalArgumentException: object is not an instance of declaring class
at org.datalis.rest.api.server.reporting.ReportingTest.reportingTest(ReportingTest.java:15)
Do you know how I can fix this issue?
Aucun commentaire:
Enregistrer un commentaire