Skip to content

Commit 2fc8f6e

Browse files
committed
Meta-annotate @SpringBatchTest with @ExtendWith(SpringExtension.class)
This is a WIP. Need to add test with JUnit Jupiter.
1 parent 8e8f9c8 commit 2fc8f6e

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

build.gradle

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ allprojects {
8585
jettisonVersion = '1.2' //? => upgrade to 1.4 and the build fails (deprecated anyway via xstream)
8686
jmsVersion = '2.0.1'
8787
junitVersion = '4.13'
88+
junitJupiterVersion = '5.6.0'
8889
log4jVersion = '2.13.0'
8990
mysqlVersion = '8.0.18'
9091
mockitoVersion = '3.1.0'
@@ -517,6 +518,8 @@ project('spring-batch-test') {
517518

518519
optional "org.aspectj:aspectjrt:$aspectjVersion"
519520
optional "javax.batch:javax.batch-api:$javaxBatchApiVersion"
521+
optional "org.junit.jupiter:junit-jupiter-api:$junitJupiterVersion"
522+
520523
}
521524
}
522525

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,14 @@
2222
import java.lang.annotation.RetentionPolicy;
2323
import java.lang.annotation.Target;
2424

25+
import org.junit.jupiter.api.extension.ExtendWith;
26+
2527
import org.springframework.batch.test.JobLauncherTestUtils;
2628
import org.springframework.batch.test.JobRepositoryTestUtils;
2729
import org.springframework.batch.test.JobScopeTestExecutionListener;
2830
import org.springframework.batch.test.StepScopeTestExecutionListener;
2931
import org.springframework.test.context.TestExecutionListeners;
32+
import org.springframework.test.context.junit.jupiter.SpringExtension;
3033

3134
/**
3235
* Annotation that can be specified on a test class that runs Spring Batch based tests.
@@ -94,5 +97,6 @@
9497
listeners = {StepScopeTestExecutionListener.class, JobScopeTestExecutionListener.class},
9598
mergeMode = TestExecutionListeners.MergeMode.MERGE_WITH_DEFAULTS
9699
)
100+
@ExtendWith(SpringExtension.class)
97101
public @interface SpringBatchTest {
98102
}

0 commit comments

Comments
 (0)