|
|
|
[[testcontext-framework]]
|
|
|
|
= Spring TestContext Framework
|
|
|
|
:page-section-summary-toc: 1
|
|
|
|
|
|
|
|
The Spring TestContext Framework (located in the `org.springframework.test.context`
|
|
|
|
package) provides generic, annotation-driven unit and integration testing support that is
|
|
|
|
agnostic of the testing framework in use. The TestContext framework also places a great
|
|
|
|
deal of importance on convention over configuration, with reasonable defaults that you
|
|
|
|
can override through annotation-based configuration.
|
|
|
|
|
|
|
|
In addition to generic testing infrastructure, the TestContext framework provides
|
|
|
|
explicit support for JUnit 4, JUnit Jupiter (AKA JUnit 5), and TestNG. For JUnit 4 and
|
|
|
|
TestNG, Spring provides `abstract` support classes. Furthermore, Spring provides a custom
|
|
|
|
JUnit `Runner` and custom JUnit `Rules` for JUnit 4 and a custom `Extension` for JUnit
|
|
|
|
Jupiter that let you write so-called POJO test classes. POJO test classes are not
|
|
|
|
required to extend a particular class hierarchy, such as the `abstract` support classes.
|
|
|
|
|
|
|
|
The following section provides an overview of the internals of the TestContext framework.
|
|
|
|
If you are interested only in using the framework and are not interested in extending it
|
|
|
|
with your own custom listeners or custom loaders, feel free to go directly to the
|
|
|
|
configuration (xref:testing/testcontext-framework/ctx-management.adoc[context management],
|
|
|
|
xref:testing/testcontext-framework/fixture-di.adoc[dependency injection], xref:testing/testcontext-framework/tx.adoc[transaction management]
|
|
|
|
), xref:testing/testcontext-framework/support-classes.adoc[support classes], and
|
|
|
|
xref:testing/annotations.adoc[annotation support] sections.
|
|
|
|
|
|
|
|
|