Skip to content

Commit 979508a

Browse files
committed
Remove JUnit 4 dependency from all modules except spring-test
This commit removes the JUnit 4 dependency from all modules except spring-test which provides explicit JUnit 4 support. This commit also includes the following. - migration from JUnit 4 assertions to JUnit Jupiter assertions in all Kotlin tests - migration from JUnit 4 assumptions in Spring's TestGroup support to JUnit Jupiter assumptions, based on org.opentest4j.TestAbortedException - introduction of a new TestGroups utility class than can be used from existing JUnit 4 tests in the spring-test module in order to perform assumptions using JUnit 4's Assume class See gh-23451
1 parent 3f3e419 commit 979508a

File tree

43 files changed

+159
-111
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+159
-111
lines changed

build.gradle

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,6 @@ configure(allprojects) { project ->
138138
dependencies {
139139
testCompile("org.junit.jupiter:junit-jupiter-api")
140140
testCompile("org.junit.jupiter:junit-jupiter-params")
141-
testCompile("junit:junit:4.13-beta-3") {
142-
exclude group: "org.hamcrest", module: "hamcrest-core"
143-
}
144141
testCompile("org.mockito:mockito-core:3.0.0") {
145142
exclude group: "org.hamcrest", module: "hamcrest-core"
146143
}
@@ -151,7 +148,6 @@ configure(allprojects) { project ->
151148
// Pull in the latest JUnit 5 Launcher API to ensure proper support in IDEs.
152149
testRuntime("org.junit.platform:junit-platform-launcher")
153150
testRuntime("org.junit.jupiter:junit-jupiter-engine")
154-
testRuntime("org.junit.vintage:junit-vintage-engine")
155151
testRuntime("org.apache.logging.log4j:log4j-core:${log4jVersion}")
156152
testRuntime("org.apache.logging.log4j:log4j-slf4j-impl:${log4jVersion}")
157153
testRuntime("org.apache.logging.log4j:log4j-jul:${log4jVersion}")

spring-beans/src/test/java/org/springframework/beans/factory/serviceloader/ServiceLoaderTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
import org.springframework.beans.factory.support.RootBeanDefinition;
2727

2828
import static org.assertj.core.api.Assertions.assertThat;
29-
import static org.junit.Assume.assumeTrue;
29+
import static org.junit.jupiter.api.Assumptions.assumeTrue;
3030

3131
/**
3232
* @author Juergen Hoeller

spring-beans/src/test/kotlin/org/springframework/beans/KotlinBeanUtilsTests.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
package org.springframework.beans
1818

19-
import org.junit.Assert.*
19+
import org.junit.jupiter.api.Assertions.*
2020
import org.junit.jupiter.api.Test
2121

2222
/**

spring-beans/src/test/kotlin/org/springframework/beans/factory/annotation/KotlinAutowiredTests.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ import org.springframework.beans.factory.support.DefaultListableBeanFactory
2222
import org.springframework.beans.factory.support.RootBeanDefinition
2323
import org.springframework.tests.sample.beans.TestBean
2424

25-
import org.junit.Assert.*
25+
import org.junit.jupiter.api.Assertions.*
26+
import org.junit.jupiter.api.fail
2627
import org.springframework.beans.factory.BeanCreationException
2728
import org.springframework.tests.sample.beans.Colour
2829

spring-context/src/test/kotlin/org/springframework/context/annotation/AnnotationConfigApplicationContextExtensionsTests.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
package org.springframework.context.annotation
1818

19-
import org.junit.Assert.assertNotNull
19+
import org.junit.jupiter.api.Assertions.assertNotNull
2020
import org.junit.jupiter.api.Test
2121
import org.springframework.beans.factory.getBean
2222
import org.springframework.context.support.registerBean

spring-context/src/test/kotlin/org/springframework/context/annotation/KotlinConfigurationClassTests.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616

1717
package org.springframework.context.annotation
1818

19-
import org.junit.Assert.*
19+
import org.junit.jupiter.api.Assertions.*
20+
import org.junit.jupiter.api.fail
2021
import org.junit.jupiter.api.Test
2122
import org.springframework.beans.factory.getBean
2223
import org.springframework.beans.factory.parsing.BeanDefinitionParsingException

spring-context/src/test/kotlin/org/springframework/context/annotation/Spr16022Tests.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
package org.springframework.context.annotation
1818

19-
import org.junit.Assert.assertEquals
19+
import org.junit.jupiter.api.Assertions.assertEquals
2020
import org.junit.jupiter.api.Test
2121
import org.springframework.beans.factory.BeanFactory
2222
import org.springframework.beans.factory.getBean

spring-context/src/test/kotlin/org/springframework/context/support/BeanDefinitionDslTests.kt

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@
1616

1717
package org.springframework.context.support
1818

19-
import org.junit.Assert.*
19+
import org.junit.jupiter.api.Assertions.assertEquals
20+
import org.junit.jupiter.api.Assertions.assertNotNull
21+
import org.junit.jupiter.api.Assertions.assertTrue
22+
import org.junit.jupiter.api.fail
2023
import org.junit.jupiter.api.Test
2124
import org.springframework.beans.factory.NoSuchBeanDefinitionException
2225
import org.springframework.beans.factory.getBean
@@ -28,7 +31,7 @@ import java.util.stream.Collectors
2831

2932
@Suppress("UNUSED_EXPRESSION")
3033
class BeanDefinitionDslTests {
31-
34+
3235
@Test
3336
fun `Declare beans with the functional Kotlin DSL`() {
3437
val beans = beans {
@@ -193,12 +196,12 @@ class BeanDefinitionDslTests {
193196

194197
try {
195198
context.getBean<Foo>()
196-
fail()
199+
fail("should have thrown an Exception")
197200
} catch (ignored: Exception) {
198201
}
199202
try {
200203
context.getBean<FooFoo>()
201-
fail()
204+
fail("should have thrown an Exception")
202205
} catch (ignored: Exception) {
203206
}
204207
}

spring-context/src/test/kotlin/org/springframework/context/support/GenericApplicationContextExtensionsTests.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
package org.springframework.context.support
1818

19-
import org.junit.Assert.assertNotNull
19+
import org.junit.jupiter.api.Assertions.assertNotNull
2020
import org.junit.jupiter.api.Test
2121
import org.springframework.beans.factory.getBean
2222

spring-context/src/test/kotlin/org/springframework/ui/ModelExtensionsTests.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616

1717
package org.springframework.ui
1818

19-
import org.junit.Assert.assertEquals
20-
import org.junit.Assert.assertTrue
19+
import org.junit.jupiter.api.Assertions.assertEquals
20+
import org.junit.jupiter.api.Assertions.assertTrue
2121
import org.junit.jupiter.api.Test
2222

2323
/**

0 commit comments

Comments
 (0)