Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
e77e070e
S
spring-framework
项目概览
爱吃血肠
/
spring-framework
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
spring-framework
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
e77e070e
编写于
7月 06, 2009
作者:
S
Sam Brannen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[SPR-4702] Reference manual updates
上级
1f087b41
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
30 addition
and
9 deletion
+30
-9
spring-framework-reference/src/testing.xml
spring-framework-reference/src/testing.xml
+30
-9
未找到文件。
spring-framework-reference/src/testing.xml
浏览文件 @
e77e070e
...
...
@@ -409,7 +409,7 @@
<emphasis>
Spring-specific
</emphasis>
annotations that you can use in
your unit and integration tests in conjunction with the TestContext
framework. Refer to the respective JavaDoc for further information,
including default attribute values, etc.
</para>
including default attribute values,
attribute aliases,
etc.
</para>
<itemizedlist>
<listitem>
...
...
@@ -419,10 +419,10 @@
<para>
Defines class-level metadata which is used to determine how to
load and configure an
<interfacename>
ApplicationContext
</interfacename>
. Specifically,
@ContextConfiguration defines the application context resourc
e
<literal>
locations
</literal>
to load as well as the
<interfacename>
ContextLoader
</interfacename>
strategy to use for
loading the context.
</para>
<interfacename>
@ContextConfiguration
</interfacename>
defines th
e
application context resource
<literal>
locations
</literal>
to
load as well as the
<interfacename>
ContextLoader
</interfacename>
strategy to use for
loading the context.
</para>
<programlisting
language=
"java"
>
@ContextConfiguration(locations={"example/test-context.xml"}, loader=CustomContextLoader.class)
public class CustomConfiguredApplicationContextTests {
...
...
@@ -442,16 +442,37 @@ public class CustomConfiguredApplicationContextTests {
role=
"bold"
><interfacename>
@DirtiesContext
</interfacename></emphasis></para>
<para>
The presence of this annotation on a test method indicates
that the underlying Spring container is 'dirtied' during the
execution of the test method, and thus must be rebuilt after the
test method finishes execution (regardless of whether the test
passed or not).
</para>
that the underlying Spring container has been
<emphasis>
dirtied
</emphasis>
during the execution of the test method and thus must be closed after the
test method finishes execution (regardless of whether the annotated test
passed or not). Similarly, if a test class is annotated with
<interfacename>
@DirtiesContext
</interfacename>
, the underlying
Spring container will be marked as dirty after all tests in the
class have completed execution.
</para>
<programlisting
language=
"java"
>
@DirtiesContext
public class ContextDirtyingTests {
<lineannotation>
// some tests that result in the Spring container being dirtied
</lineannotation>
}
</programlisting>
<programlisting
language=
"java"
>
@DirtiesContext
@Test
public void testProcessWhichDirtiesAppCtx() {
<lineannotation>
// some logic that results in the Spring container being dirtied
</lineannotation>
}
</programlisting>
<para>
Whenever an application context is marked as
<emphasis>
dirty
</emphasis>
, it will be removed from the testing
framework's cache and closed; thus the underlying Spring container will be
rebuilt for any subsequent test which requires a context with the
same set of resource locations.
</para>
<note>
<title>
Limitations of
<interfacename>
@DirtiesContext
</interfacename>
with JUnit 3.8
</title>
<para>
In a JUnit 3.8 environment
<interfacename>
@DirtiesContext
</interfacename>
is only supported on methods and thus not at the class level.
</para>
</note>
</listitem>
<listitem>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录