You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
SpringBatchTest does not work ootb with SpringBootΒ #4233
Thank you for opening this ticket. This is a valid issue, and is related to the new way test utilities are configured with @SpringBatchTest in v5. Test utilities should not autowire dependencies. I noticed that this is inconsistent as of 5.0.0-RC2 (the job under test is not autowired while the job repository and job launcher are). This has been fixed in 05bbd3f.
Now on the Boot side, things are a bit different with regard to the setup of the test context. I noticed that without importing the HelloBatch.class and using @SpringBootTest the test you shared passes. This is actually how I am expecting things to work in a Boot world: the simple fact of using @SpringBootTest should import my job configuration (without having to do it manually). This is not a Javadoc issue because the sample in the Javadoc of Spring Batch works with Spring Batch alone.
Could you please give the latest snapshots a try? I am expecting the following test to pass with the latest snapshots:
Activity
Remove dependency autowiring in test utilities
fmbenhassine commentedon Nov 16, 2022
Thank you for opening this ticket. This is a valid issue, and is related to the new way test utilities are configured with
@SpringBatchTestin v5. Test utilities should not autowire dependencies. I noticed that this is inconsistent as of5.0.0-RC2(the job under test is not autowired while the job repository and job launcher are). This has been fixed in 05bbd3f.Now on the Boot side, things are a bit different with regard to the setup of the test context. I noticed that without importing the
HelloBatch.classand using@SpringBootTestthe test you shared passes. This is actually how I am expecting things to work in a Boot world: the simple fact of using@SpringBootTestshould import my job configuration (without having to do it manually). This is not a Javadoc issue because the sample in the Javadoc of Spring Batch works with Spring Batch alone.Could you please give the latest snapshots a try? I am expecting the following test to pass with the latest snapshots:
eiswind commentedon Nov 16, 2022
I can confirm that the test passes, but it runs the job twice. (The JobLauncher from the AutoConfiguration...)
I added
then everything is fine.
Maybe this should be the default in a test?
fmbenhassine commentedon Nov 16, 2022
Thank you for taking the time to test the fix! Much appreciated π
This is not specific to Spring Batch per se. Please check/request this with the Boot team. Thank you upfront.