I have a service class to be tested.
public class MyService{
private final MyConfig myconfig;
private final WebClient webClient;
private String result;
private StepExecution stepExecution;
@BeforeStep
public void saveStepExecution(){
this.stepExecution = stepExecution);
}
@AutoWired
MyService(
MyConfig myconfig,WebClient webClient) {
this.myconfig = myconfig;
this.webClient = webClient;
}
public void someMethod(){
// does some stuff with stepexecution
}
}
My Junit test case is:
@Test
public void someTest(){
MyService myservice = new MyService();
myservice.someMethod();
}
But it gives Null pointer at stepExecution which is obvious. So, how shall I pass stepexecution from JUnit Test method?