From b4fc7b410b2f3a9ce0935b4ecb1a339f6b419238 Mon Sep 17 00:00:00 2001 From: Adib Saikali Date: Wed, 5 Feb 2014 14:12:31 -0500 Subject: [PATCH] Document that @Transactional is not supported on test lifecycle methods This commit adds a tip clarifying that TestNG's @BeforeClass and @BeforeSuite methods can not be annotated with Spring's @Transactional annotation. Closes: gh-456 --- src/docs/asciidoc/testing.adoc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/docs/asciidoc/testing.adoc b/src/docs/asciidoc/testing.adoc index f53e971d27..5b984e78a6 100644 --- a/src/docs/asciidoc/testing.adoc +++ b/src/docs/asciidoc/testing.adoc @@ -3524,6 +3524,15 @@ hierarchy runs within a transaction. Test methods that are not annotated with 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. +==== + Note that <> and <>