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
This commit is contained in:
@@ -40,10 +40,11 @@ import org.springframework.test.context.web.socket.WebSocketServletServerContain
|
||||
import org.springframework.test.web.client.samples.SampleTests;
|
||||
import org.springframework.test.web.servlet.samples.context.JavaConfigTests;
|
||||
import org.springframework.test.web.servlet.samples.context.WebAppResourceTests;
|
||||
import org.springframework.tests.Assume;
|
||||
import org.springframework.tests.TestGroup;
|
||||
import org.springframework.tests.TestGroups;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
|
||||
import static org.junit.Assume.assumeTrue;
|
||||
import static org.springframework.core.annotation.AnnotatedElementUtils.hasAnnotation;
|
||||
import static org.springframework.test.context.junit4.JUnitTestingUtils.runTestsAndAssertCounters;
|
||||
|
||||
@@ -97,7 +98,8 @@ public class SpringJUnit4ConcurrencyTests {
|
||||
|
||||
@BeforeClass
|
||||
public static void abortIfLongRunningTestGroupIsNotEnabled() {
|
||||
Assume.group(TestGroup.LONG_RUNNING);
|
||||
assumeTrue("TestGroup " + TestGroup.LONG_RUNNING + " is not active.",
|
||||
TestGroups.isGroupActive(TestGroup.LONG_RUNNING));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -36,10 +36,11 @@ import org.springframework.stereotype.Controller;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
import org.springframework.test.web.servlet.htmlunit.DelegatingWebConnection.DelegateWebConnection;
|
||||
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
|
||||
import org.springframework.tests.Assume;
|
||||
import org.springframework.tests.TestGroup;
|
||||
import org.springframework.tests.TestGroups;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.Assume.assumeTrue;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.verifyNoMoreInteractions;
|
||||
@@ -125,7 +126,8 @@ public class DelegatingWebConnectionTests {
|
||||
|
||||
@Test
|
||||
public void verifyExampleInClassLevelJavadoc() throws Exception {
|
||||
Assume.group(TestGroup.PERFORMANCE);
|
||||
assumeTrue("TestGroup " + TestGroup.PERFORMANCE + " is not active.",
|
||||
TestGroups.isGroupActive(TestGroup.PERFORMANCE));
|
||||
|
||||
WebClient webClient = new WebClient();
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ import io.mockk.mockk
|
||||
import io.mockk.verify
|
||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.jupiter.api.Assertions.assertEquals
|
||||
import org.junit.Test
|
||||
import org.reactivestreams.Publisher
|
||||
import org.springframework.core.ParameterizedTypeReference
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
package org.springframework.test.web.servlet
|
||||
|
||||
import org.hamcrest.CoreMatchers
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
import org.junit.jupiter.api.Assertions.*
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.junit.jupiter.api.assertThrows
|
||||
import org.springframework.http.HttpMethod
|
||||
import org.springframework.http.HttpStatus
|
||||
@@ -81,8 +81,8 @@ class MockMvcExtensionsTests {
|
||||
}.andDo {
|
||||
handle(handler)
|
||||
}
|
||||
Assert.assertTrue(matcherInvoked)
|
||||
Assert.assertTrue(handlerInvoked)
|
||||
assertTrue(matcherInvoked)
|
||||
assertTrue(handlerInvoked)
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user