简体   繁体   English

SpringJUnit4ClassRunner是否为每个Test或Class加载了Context?

[英]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.

相关问题 找不到 SpringJUnit4ClassRunner 类 - SpringJUnit4ClassRunner class not found SpringJUnit4ClassRunner是否为每个测试初始化​​bean? - SpringJUnit4ClassRunner initialize beans for each test? JUnit Test无法使用SpringJUnit4ClassRunner回滚 - JUnit Test not rollbacking with SpringJUnit4ClassRunner SpringJUnit4ClassRunner在JUnit测试用例结束时不关闭Application Context - SpringJUnit4ClassRunner does not close the Application Context at the end of JUnit test case 没有SpringJUnit4ClassRunner或AbstractJUnit4SpringContextTests的Spring测试上下文设置(在Selenium测试中) - Spring test context setup without SpringJUnit4ClassRunner or AbstractJUnit4SpringContextTests (in Selenium testing) SpringJUnit4ClassRunner单元测试不起作用。 错误:无法加载ApplicationContext - SpringJUnit4ClassRunner unit test does not work. Error: Failed to load ApplicationContext 初始化错误在移动或删除类后使用SpringJUnit4ClassRunner运行junit测试 - initializationError running junit test with SpringJUnit4ClassRunner after moving or deleting a class java sbt test:如果使用SpringJUnit4ClassRunner运行测试,则忽略异常 - java sbt test: exception ignored if test is run with SpringJUnit4ClassRunner SpringJUnit4ClassRunner应该初始化上下文多少次? - How many times should SpringJUnit4ClassRunner initialize it's context? SpringJUnit4ClassRunner在Java配置中定义的上下文中看不到my - SpringJUnit4ClassRunner does not see my in context defined in java config
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM