|
|
|
|
@ -16,6 +16,7 @@
@@ -16,6 +16,7 @@
|
|
|
|
|
|
|
|
|
|
package org.springframework.test.context.bean.override.mockito; |
|
|
|
|
|
|
|
|
|
import org.junit.jupiter.api.BeforeAll; |
|
|
|
|
import org.junit.jupiter.api.Nested; |
|
|
|
|
import org.junit.jupiter.api.Test; |
|
|
|
|
import org.junit.jupiter.api.extension.ExtendWith; |
|
|
|
|
@ -24,8 +25,10 @@ import org.springframework.beans.factory.annotation.Autowired;
@@ -24,8 +25,10 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.context.annotation.Bean; |
|
|
|
|
import org.springframework.context.annotation.Configuration; |
|
|
|
|
import org.springframework.test.context.ContextConfiguration; |
|
|
|
|
import org.springframework.test.context.TestContextAnnotationUtils; |
|
|
|
|
import org.springframework.test.context.junit.jupiter.SpringExtension; |
|
|
|
|
|
|
|
|
|
import static org.assertj.core.api.Assertions.assertThat; |
|
|
|
|
import static org.mockito.BDDMockito.then; |
|
|
|
|
import static org.mockito.Mockito.times; |
|
|
|
|
|
|
|
|
|
@ -38,10 +41,6 @@ import static org.mockito.Mockito.times;
@@ -38,10 +41,6 @@ import static org.mockito.Mockito.times;
|
|
|
|
|
* @since 6.2 |
|
|
|
|
*/ |
|
|
|
|
@ExtendWith(SpringExtension.class) |
|
|
|
|
// TODO Remove @ContextConfiguration declaration.
|
|
|
|
|
// @ContextConfiguration is currently required due to a bug in the TestContext framework.
|
|
|
|
|
// See https://github.com/spring-projects/spring-framework/issues/31456
|
|
|
|
|
@ContextConfiguration |
|
|
|
|
class MockitoBeanNestedTests { |
|
|
|
|
|
|
|
|
|
@MockitoBean |
|
|
|
|
@ -50,6 +49,13 @@ class MockitoBeanNestedTests {
@@ -50,6 +49,13 @@ class MockitoBeanNestedTests {
|
|
|
|
|
@Autowired |
|
|
|
|
Task task; |
|
|
|
|
|
|
|
|
|
@BeforeAll |
|
|
|
|
static void ensureNotAnnotatedWithContextConfiguration() { |
|
|
|
|
boolean hasAnnotation = |
|
|
|
|
TestContextAnnotationUtils.hasAnnotation(MockitoBeanNestedTests.class, ContextConfiguration.class); |
|
|
|
|
assertThat(hasAnnotation).isFalse(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
void mockWasInvokedOnce() { |
|
|
|
|
task.execute(); |
|
|
|
|
|