diff --git a/spring-batch-docs/modules/ROOT/pages/testing.adoc b/spring-batch-docs/modules/ROOT/pages/testing.adoc index 7030be5005..fca7e1210a 100644 --- a/spring-batch-docs/modules/ROOT/pages/testing.adoc +++ b/spring-batch-docs/modules/ROOT/pages/testing.adoc @@ -24,6 +24,8 @@ NOTE: If the test context contains a single `Job` bean definition, this bean will be autowired in `JobLauncherTestUtils`. Otherwise, the job under test should be manually set on the `JobLauncherTestUtils`. +NOTE: Spring Batch no longer supports JUnit 4. Migrate to JUnit Jupiter recommended. + [tabs] ==== diff --git a/spring-batch-test/src/main/java/org/springframework/batch/test/JobScopeTestExecutionListener.java b/spring-batch-test/src/main/java/org/springframework/batch/test/JobScopeTestExecutionListener.java index 5376d5a87a..75aa3549e6 100644 --- a/spring-batch-test/src/main/java/org/springframework/batch/test/JobScopeTestExecutionListener.java +++ b/spring-batch-test/src/main/java/org/springframework/batch/test/JobScopeTestExecutionListener.java @@ -36,7 +36,7 @@ *
* @ContextConfiguration * @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, JobScopeTestExecutionListener.class }) - * @RunWith(SpringJUnit4ClassRunner.class) + * @SpringJUnitConfig * public class JobScopeTestExecutionListenerIntegrationTests { * * // A job-scoped dependency configured in the ApplicationContext @@ -62,6 +62,7 @@ * @author Dave Syer * @author Jimmy Praet * @author Mahmoud Ben Hassine + * @author Hyuntae Park */ public class JobScopeTestExecutionListener implements TestExecutionListener { diff --git a/spring-batch-test/src/main/java/org/springframework/batch/test/StepScopeTestExecutionListener.java b/spring-batch-test/src/main/java/org/springframework/batch/test/StepScopeTestExecutionListener.java index 1deea865bd..73dc3dce62 100644 --- a/spring-batch-test/src/main/java/org/springframework/batch/test/StepScopeTestExecutionListener.java +++ b/spring-batch-test/src/main/java/org/springframework/batch/test/StepScopeTestExecutionListener.java @@ -37,7 +37,7 @@ ** @ContextConfiguration * @TestExecutionListeners( { DependencyInjectionTestExecutionListener.class, StepScopeTestExecutionListener.class }) - * @RunWith(SpringJUnit4ClassRunner.class) + * @SpringJUnitConfig * public class StepScopeTestExecutionListenerIntegrationTests { * * // A step-scoped dependency configured in the ApplicationContext @@ -63,6 +63,7 @@ * @author Dave Syer * @author Chris Schaefer * @author Mahmoud Ben Hassine + * @author Hyuntae Park */ public class StepScopeTestExecutionListener implements TestExecutionListener { diff --git a/spring-batch-test/src/main/java/org/springframework/batch/test/context/SpringBatchTest.java b/spring-batch-test/src/main/java/org/springframework/batch/test/context/SpringBatchTest.java index a597f95b9b..e761790fd5 100644 --- a/spring-batch-test/src/main/java/org/springframework/batch/test/context/SpringBatchTest.java +++ b/spring-batch-test/src/main/java/org/springframework/batch/test/context/SpringBatchTest.java @@ -43,44 +43,6 @@ * {@link JobScopeTestExecutionListener} as test execution listeners which are required to * test step/job scoped beans. * - *- * A typical usage of this annotation with JUnit 4 is like the following: - * - *
- * @RunWith(SpringRunner.class) - * @SpringBatchTest - * @ContextConfiguration(classes = MyBatchJobConfiguration.class) - * public class MyBatchJobTests { - * - * @Autowired - * private JobLauncherTestUtils jobLauncherTestUtils; - * - * @Autowired - * private JobRepositoryTestUtils jobRepositoryTestUtils; - * - * @Autowired - * private Job jobUnderTest; - * - * @Before - * public void setup() { - * this.jobRepositoryTestUtils.removeJobExecutions(); - * this.jobLauncherTestUtils.setJob(this.jobUnderTest); // this is optional if the job is unique - * } - * - * @Test - * public void testMyJob() throws Exception { - * // given - * JobParameters jobParameters = this.jobLauncherTestUtils.getUniqueJobParameters(); - * - * // when - * JobExecution jobExecution = this.jobLauncherTestUtils.launchJob(jobParameters); - * - * // then - * Assert.assertEquals(ExitStatus.COMPLETED, jobExecution.getExitStatus()); - * } - * - * } - ** * For JUnit 5, this annotation can be used without manually registering the * {@link SpringExtension} since {@code @SpringBatchTest} is meta-annotated with @@ -127,9 +89,11 @@ * In the previous example, the imported configuration class *MyBatchJobConfiguration
is expected to have such beans defined in it (or * imported from another configuration class). + * JUnit4 is deprecated in Spring Batch 6.0.0 and will be removed in a future release. * * @author Mahmoud Ben Hassine * @author Taeik Lim + * @author Hyuntae Park * @since 4.1 * @see JobLauncherTestUtils * @see JobRepositoryTestUtils