[英]Did SpringJUnit4ClassRunner load the Context for every Test or for Class?
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? Spring是为每个测试或每个测试类加载了Context new,还是仅为Test Run加载一次?
Out of the box, with no configuration changes Spring should have only loaded the context once for each test suite. 开箱即用,没有配置更改Spring应该只为每个测试套件加载一次上下文。
By default, once loaded, the configured ApplicationContext is reused for each test.
默认情况下,一旦加载,配置的ApplicationContext将重复用于每个测试。 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.
在此上下文中,术语测试套件意味着所有测试都在同一JVM中运行 - 例如,所有测试都是针对给定项目或模块从Ant,Maven或Gradle构建的。 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.
在不太可能的情况下,测试会破坏应用程序上下文并需要重新加载 - 例如,通过修改bean定义或应用程序对象的状态 - 可以将TestContext框架配置为在执行下一个之前重新加载配置并重建应用程序上下文测试。
Source: http://static.springsource.org/spring/docs/3.2.x/spring-framework-reference/html/testing.html#testcontext-ctx-management 资料来源: http : //static.springsource.org/spring/docs/3.2.x/spring-framework-reference/html/testing.html#testcontext-ctx-management
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.