@ContextHierarchy 在继承场景之外有用吗?
Is @ContextHierarchy useful out of the inheritance scenario?
我的意思是,如果我用它注释不相关的 classes,会 Spring 推断出逻辑层次还是它是一种仅适用于物理层次的机制(抽象 class 和子,例如 Spring 文档中的示例)
我想要的是一种告诉上下文缓存重用某些配置的方法 classes 由不同的测试 classes 使用,它们不符合套件(即具有相同的上下文配置身份 http://docs.spring.io/spring/docs/current/spring-framework-reference/html/integration-testing.html#testcontext-ctx-management-caching)
if I annotate unrelated classes with it, will Spring infer the logical hierarchy
不,@ContextHierarchy
不会神奇地推断 来自 class 它不知道的任何东西。
如 Spring 框架参考手册中所示,有两种使用 @ContextHierarchy
的基本场景。
- 用于在单个测试中创建上下文层次结构 class。 (参见参考手册中的
ControllerIntegrationTests
)
- 用于在测试 class 层次结构中创建上下文层次结构。 (参见参考手册中的
SoapWebServiceTests
)
What I am after is a way to tell the context cache to reuse certain configuration classes used by different test classes which don´t conform a suite
只要这些不同测试的配置 classes 产生完全相同的 context 缓存键 (参见 Spring 参考手册),那么这已经有效了。这实际上是 Spring TestContext 框架的主要优势之一。
如果你的意思是别的,那我不太确定你在问什么。
此致,
Sam(Spring TestContext Framework 的作者)
我的意思是,如果我用它注释不相关的 classes,会 Spring 推断出逻辑层次还是它是一种仅适用于物理层次的机制(抽象 class 和子,例如 Spring 文档中的示例)
我想要的是一种告诉上下文缓存重用某些配置的方法 classes 由不同的测试 classes 使用,它们不符合套件(即具有相同的上下文配置身份 http://docs.spring.io/spring/docs/current/spring-framework-reference/html/integration-testing.html#testcontext-ctx-management-caching)
if I annotate unrelated classes with it, will Spring infer the logical hierarchy
不,@ContextHierarchy
不会神奇地推断 来自 class 它不知道的任何东西。
如 Spring 框架参考手册中所示,有两种使用 @ContextHierarchy
的基本场景。
- 用于在单个测试中创建上下文层次结构 class。 (参见参考手册中的
ControllerIntegrationTests
) - 用于在测试 class 层次结构中创建上下文层次结构。 (参见参考手册中的
SoapWebServiceTests
)
What I am after is a way to tell the context cache to reuse certain configuration classes used by different test classes which don´t conform a suite
只要这些不同测试的配置 classes 产生完全相同的 context 缓存键 (参见 Spring 参考手册),那么这已经有效了。这实际上是 Spring TestContext 框架的主要优势之一。
如果你的意思是别的,那我不太确定你在问什么。
此致,
Sam(Spring TestContext Framework 的作者)