Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
9f751ef9
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,体验更适合开发者的 AI 搜索 >>
提交
9f751ef9
编写于
2月 22, 2019
作者:
S
Sam Brannen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Polish contribution
See: gh-456
上级
b4fc7b41
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
16 addition
and
8 deletion
+16
-8
src/docs/asciidoc/testing.adoc
src/docs/asciidoc/testing.adoc
+16
-8
未找到文件。
src/docs/asciidoc/testing.adoc
浏览文件 @
9f751ef9
...
...
@@ -3520,17 +3520,25 @@ Annotating a test method with `@Transactional` causes the test to be run within
transaction
that
is
,
by
default
,
automatically
rolled
back
after
completion
of
the
test
.
If
a
test
class
is
annotated
with
`@
Transactional
`,
each
test
method
within
that
class
hierarchy
runs
within
a
transaction
.
Test
methods
that
are
not
annotated
with
`@
Transactional
`
(
at
the
class
or
method
level
)
are
not
run
within
a
transaction
.
Furthermore
,
tests
that
are
annotated
with
`@
Transactional
`
but
have
the
`
propagation
`
type
set
to
`
NOT_SUPPORTED
`
are
not
run
within
a
transaction
.
`@
Transactional
`
(
at
the
class
or
method
level
)
are
not
run
within
a
transaction
.
Note
that
`@
Transactional
`
is
not
supported
on
test
lifecycle
methods
—
for
example
,
methods
annotated
with
JUnit
Jupiter
's `@BeforeAll`, `@BeforeEach`, etc. Furthermore, tests that
are annotated with `@Transactional` but have the `propagation` type set to
`NOT_SUPPORTED` are not run within a transaction.
[TIP]
====
When
using
TestNG
`@
BeforeClass
`,`@
BeforeSuite
`
methods
can
not
be
used
with
the
`@
Transactional
`
annotation
,
as
they
are
considered
non
transactional
methods
by
the
the
spring
text
contetxt
framework
.
However
,
you
can
inject
a
`
PlatfromTransactionManager
`
or
a
`
TransactionTemplate
`
and
use
it
within
`@
BeforeClass
`
method
to
perform
a
transaction
.
Method-level lifecycle methods — for example, methods annotated with JUnit Jupiter'
s
`@
BeforeEach
`
or
`@
AfterEach
`
—
are
run
within
a
test
-
managed
transaction
.
On
the
other
hand
,
suite
-
level
and
class
-
level
lifecycle
methods
—
for
example
,
methods
annotated
with
JUnit
Jupiter
's `@BeforeAll` or `@AfterAll` and methods annotated with TestNG'
s
`@
BeforeSuite
`,
`@
AfterSuite
`,
`@
BeforeClass
`,
or
`@
AfterClass
`
—
are
_not_
run
within
a
test
-
managed
transaction
.
If
you
need
to
execute
code
in
a
suite
-
level
or
class
-
level
lifecycle
method
within
a
transaction
,
you
may
wish
to
inject
a
corresponding
`
PlatformTransactionManager
`
into
your
test
class
and
then
use
that
with
a
`
TransactionTemplate
`
for
programmatic
transaction
management
.
====
Note
that
<<
testcontext
-
support
-
classes
-
junit4
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录