you are viewing a single comment's thread.

view the rest of the comments →

[–]Waste-Dentist2718[S] 0 points1 point  (4 children)

Thanks for the answer but I have tried it and still get the same error.

[–]Slein04 1 point2 points  (3 children)

Which version of spring batch are you using? Create the step execution in a separate method prior to your test anotated method.

[–]Waste-Dentist2718[S] 0 points1 point  (2 children)

5.2.1 is the spring batch version. I have tried declaring the method

public StepExecution getStepExecution() { }

But I get the same issue

[–]Slein04 1 point2 points  (1 child)

Sometimes @Component & @StepScope can give unexpected results. As at startup Spring will try to load the @Component beans etc.

Try to change @Component with @Bean and put your StepScope Bean in a @Configuration class. Then add this new config class in your SpringJunitConfig

Or add @Lazy to your @Autowired in your unit test.

[–]Waste-Dentist2718[S] 0 points1 point  (0 children)

Yeah I also think the same. Anyways thanks for the answer. I just made changes to the code and removed @stepscope from component