-
Notifications
You must be signed in to change notification settings - Fork 38.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce context failure threshold support in the TestContext framework
This set of commits introduces ApplicationContext "failure threshold" support in the Spring TestContext Framework (TCF). Specifically, this new feature avoids repeated attempts to load a failing ApplicationContext in the TCF, based on a failure threshold which defaults to 1 but can be configured via a system property. See individual commits for details. Closes gh-14182
- Loading branch information
Showing
8 changed files
with
318 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
.../ROOT/pages/testing/testcontext-framework/ctx-management/failure-threshold.adoc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
[[testcontext-ctx-management-failure-threshold]] | ||
= Context Failure Threshold | ||
|
||
As of Spring Framework 6.1, a context _failure threshold_ policy is in place which helps | ||
avoid repeated attempts to load a failing `ApplicationContext`. By default, the failure | ||
threshold is set to `1` which means that only one attempt will be made to load an | ||
`ApplicationContext` for a given context cache key (see | ||
xref:testing/testcontext-framework/ctx-management/caching.adoc[Context Caching]). Any | ||
subsequent attempt to load the `ApplicationContext` for the same context cache key will | ||
result in an immediate `IllegalStateException` with an error message which explains that | ||
the attempt was preemptively skipped. This behavior allows individual test classes and | ||
test suites to fail faster by avoiding repeated attempts to load an `ApplicationContext` | ||
that will never successfully load -- for example, due to a configuration error or a missing | ||
external resource that prevents the context from loading in the current environment. | ||
|
||
You can configure the context failure threshold from the command line or a build script | ||
by setting a JVM system property named `spring.test.context.failure.threshold` with a | ||
positive integer value. As an alternative, you can set the same property via the | ||
xref:appendix.adoc#appendix-spring-properties[`SpringProperties`] mechanism. | ||
|
||
NOTE: If you wish to effectively disable the context failure threshold, you can set the | ||
property to a very large value. For example, from the command line you could set the | ||
system property via `-Dspring.test.context.failure.threshold=1000000`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.