From 0f6a13c9b3d4f3a9db50676098c535097cd24e2c Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Thu, 8 Feb 2018 15:02:46 +0100 Subject: [PATCH] Warn users about the caching implications of @MockBean and @SpyBean Closes gh-10182 --- .../src/main/asciidoc/spring-boot-features.adoc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc b/spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc index bd179f89e4..7cb43298c1 100644 --- a/spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc +++ b/spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc @@ -6148,6 +6148,9 @@ implementation: Additionally, you can use `@SpyBean` to wrap any existing bean with a Mockito `spy`. See the {dc-spring-boot-test}/mock/mockito/SpyBean.{dc-ext}[Javadoc] for full details. +NOTE: While Spring's test framework caches application contexts between tests and reuses +a context for tests sharing the same configuration, the use of `@MockBean` or `@SpyBean` +influences the cache key, which will most likely increase the number of contexts. [[boot-features-testing-spring-boot-applications-testing-autoconfigured-tests]] ==== Auto-configured Tests