Skip to content

Deprecated JUnit4 #4835

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions spring-batch-docs/modules/ROOT/pages/testing.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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]
====
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
* <pre>
* &#064;ContextConfiguration
* &#064;TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, JobScopeTestExecutionListener.class })
* &#064;RunWith(SpringJUnit4ClassRunner.class)
* &#064;SpringJUnitConfig
* public class JobScopeTestExecutionListenerIntegrationTests {
*
* // A job-scoped dependency configured in the ApplicationContext
Expand All @@ -62,6 +62,7 @@
* @author Dave Syer
* @author Jimmy Praet
* @author Mahmoud Ben Hassine
* @author Hyuntae Park
*/
public class JobScopeTestExecutionListener implements TestExecutionListener {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
* <pre>
* &#064;ContextConfiguration
* &#064;TestExecutionListeners( { DependencyInjectionTestExecutionListener.class, StepScopeTestExecutionListener.class })
* &#064;RunWith(SpringJUnit4ClassRunner.class)
* &#064;SpringJUnitConfig
* public class StepScopeTestExecutionListenerIntegrationTests {
*
* // A step-scoped dependency configured in the ApplicationContext
Expand All @@ -63,6 +63,7 @@
* @author Dave Syer
* @author Chris Schaefer
* @author Mahmoud Ben Hassine
* @author Hyuntae Park
*/
public class StepScopeTestExecutionListener implements TestExecutionListener {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,44 +43,6 @@
* {@link JobScopeTestExecutionListener} as test execution listeners which are required to
* test step/job scoped beans.</li>
* </ul>
* <p>
* A typical usage of this annotation with JUnit 4 is like the following:
*
* <pre class="code">
* &#064;RunWith(SpringRunner.class)
* &#064;SpringBatchTest
* &#064;ContextConfiguration(classes = MyBatchJobConfiguration.class)
* public class MyBatchJobTests {
*
* &#064;Autowired
* private JobLauncherTestUtils jobLauncherTestUtils;
*
* &#064;Autowired
* private JobRepositoryTestUtils jobRepositoryTestUtils;
*
* &#064;Autowired
* private Job jobUnderTest;
*
* &#064;Before
* public void setup() {
* this.jobRepositoryTestUtils.removeJobExecutions();
* this.jobLauncherTestUtils.setJob(this.jobUnderTest); // this is optional if the job is unique
* }
*
* &#064;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());
* }
*
* }
* </pre>
*
* For JUnit 5, this annotation can be used without manually registering the
* {@link SpringExtension} since {@code @SpringBatchTest} is meta-annotated with
Expand Down Expand Up @@ -127,9 +89,11 @@
* In the previous example, the imported configuration class
* <code>MyBatchJobConfiguration</code> is expected to have such beans defined in it (or
* imported from another configuration class). </strong>
* 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
Expand Down