My problem is that some tests fail. I think that the function destroys the context and because of this the test failed.
Has Spring loaded a new context for each test, or for each test class, or only once for a test run?
Out of the box with no configuration changes, Spring should only load the context once for each test suite.
By default, after loading, the configured ApplicationContext is reused for each test. Thus, the installation cost arises only once per set test and subsequent test execution is much faster. In this context, the term βtest suiteβ means that all tests run in the same JVM β for example, all tests run from the Ant, Maven, or Gradle assembly for a given project or module. In the unlikely event that a test corrupts the application context and requires a reboot β for example, by changing the bean definition or state of the application object β the TestContext framework can be configured to reload the configuration and rebuild the application context before performing the next test.
Source: http://static.springsource.org/spring/docs/3.2.x/spring-framework-reference/html/testing.html#testcontext-ctx-management