Reputation: 66
my Problem is that some test are Failed. I think that a Function destroy the Context and because of that the Test failed.
Did Spring load the Context new for every Test or for every Test Class or just once for the Test Run?
Upvotes: 4
Views: 2187
Reputation: 94439
Out of the box, with no configuration changes Spring should have only loaded the context once for each test suite.
By default, once loaded, the configured ApplicationContext is reused for each test. Thus the setup cost is incurred only once per test suite, and subsequent test execution is much faster. In this context, the term test suite means all tests run in the same JVM — for example, all tests run from an Ant, Maven, or Gradle build for a given project or module. In the unlikely case that a test corrupts the application context and requires reloading — for example, by modifying a bean definition or the state of an application object — the TestContext framework can be configured to reload the configuration and rebuild the application context before executing the next test.
Upvotes: 7