Skip to content

Commit 15d24b3

Browse files
committed
Update documentation with expected configuration to use @SpringBatchTest
Resolves #3699
1 parent a785c07 commit 15d24b3

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

spring-batch-docs/asciidoc/testing.adoc

+10
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,16 @@ Starting from v4.1, it is also possible to inject Spring Batch test utilities
3434
like the `JobLauncherTestUtils` and `JobRepositoryTestUtils` in the test context
3535
using the `@SpringBatchTest` annotation.
3636

37+
[NOTE]
38+
====
39+
It should be noted that `JobLauncherTestUtils` requires a `Job` bean and that
40+
`JobRepositoryTestUtils` requires a `DataSource` bean. Since `@SpringBatchTest`
41+
registers a `JobLauncherTestUtils` and a `JobRepositoryTestUtils` in the test
42+
context, it is expected that the test context contains a single autowire candidate
43+
for a `Job` and a `DataSource` (either a single bean definition or one that is
44+
annotated with `org.springframework.context.annotation.Primary`).
45+
====
46+
3747
[role="javaContent"]
3848
The following Java example shows the annotations in use:
3949

spring-batch-test/src/main/java/org/springframework/batch/test/context/SpringBatchTest.java

+13
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,19 @@
116116
*
117117
* }
118118
* </pre>
119+
*
120+
* <p><strong>
121+
* It should be noted that {@link JobLauncherTestUtils} requires a
122+
* {@link org.springframework.batch.core.Job} bean and that
123+
* {@link JobRepositoryTestUtils} requires a {@link javax.sql.DataSource} bean.
124+
* Since this annotation registers a {@link JobLauncherTestUtils} and a
125+
* {@link JobRepositoryTestUtils} in the test context, it is expected that the
126+
* test context contains a single autowire candidate for a
127+
* {@link org.springframework.batch.core.Job} and a {@link javax.sql.DataSource}
128+
* (either a single bean definition or one that is
129+
* annotated with {@link org.springframework.context.annotation.Primary}).
130+
* </strong></p>
131+
*
119132
* @author Mahmoud Ben Hassine
120133
* @since 4.1
121134
* @see JobLauncherTestUtils

0 commit comments

Comments
 (0)