diff --git a/spring-test/src/main/java/org/springframework/test/context/transaction/TransactionalTestExecutionListener.java b/spring-test/src/main/java/org/springframework/test/context/transaction/TransactionalTestExecutionListener.java
index 8290bbadfc35..f1b08d6294e2 100644
--- a/spring-test/src/main/java/org/springframework/test/context/transaction/TransactionalTestExecutionListener.java
+++ b/spring-test/src/main/java/org/springframework/test/context/transaction/TransactionalTestExecutionListener.java
@@ -79,6 +79,7 @@
* are annotated with {@code @Transactional} but have the
* {@link Transactional#propagation propagation} type set to
* {@link org.springframework.transaction.annotation.Propagation#NOT_SUPPORTED NOT_SUPPORTED}
+ * or {@link org.springframework.transaction.annotation.Propagation#NEVER NEVER}
* will not be run within a transaction.
*
*
Declarative Rollback and Commit Behavior
@@ -123,7 +124,8 @@
* Attribute | Supported for test-managed transactions |
* {@link Transactional#value value} and {@link Transactional#transactionManager transactionManager} | yes |
* {@link Transactional#propagation propagation} |
- * only {@link org.springframework.transaction.annotation.Propagation#NOT_SUPPORTED NOT_SUPPORTED} is supported |
+ * only {@link org.springframework.transaction.annotation.Propagation#NOT_SUPPORTED NOT_SUPPORTED}
+ * and {@link org.springframework.transaction.annotation.Propagation#NEVER NEVER} are supported |
* {@link Transactional#isolation isolation} | no |
* {@link Transactional#timeout timeout} | no |
* {@link Transactional#readOnly readOnly} | no |
@@ -213,7 +215,8 @@ public void beforeTestMethod(final TestContext testContext) throws Exception {
"] found for test context " + testContext);
}
- if (transactionAttribute.getPropagationBehavior() == TransactionDefinition.PROPAGATION_NOT_SUPPORTED) {
+ if (transactionAttribute.getPropagationBehavior() == TransactionDefinition.PROPAGATION_NOT_SUPPORTED ||
+ transactionAttribute.getPropagationBehavior() == TransactionDefinition.PROPAGATION_NEVER) {
return;
}
diff --git a/spring-test/src/test/java/org/springframework/test/context/transaction/programmatic/ProgrammaticTxMgmtTests.java b/spring-test/src/test/java/org/springframework/test/context/transaction/programmatic/ProgrammaticTxMgmtTests.java
index fb3cc33f20b9..db72c16ed2d7 100644
--- a/spring-test/src/test/java/org/springframework/test/context/transaction/programmatic/ProgrammaticTxMgmtTests.java
+++ b/spring-test/src/test/java/org/springframework/test/context/transaction/programmatic/ProgrammaticTxMgmtTests.java
@@ -134,7 +134,7 @@ void isFlaggedForRollbackWithNonExistentTransactionContext() {
}
@Test
- @Transactional(propagation = Propagation.NOT_SUPPORTED)
+ @Transactional(propagation = Propagation.NEVER)
void startTxWithNonExistentTransactionContext() {
assertThatIllegalStateException().isThrownBy(TestTransaction::start);
}
@@ -145,7 +145,7 @@ void startTxWithExistingTransaction() {
}
@Test
- @Transactional(propagation = Propagation.NOT_SUPPORTED)
+ @Transactional(propagation = Propagation.NEVER)
void endTxWithNonExistentTransactionContext() {
assertThatIllegalStateException().isThrownBy(TestTransaction::end);
}
diff --git a/src/docs/asciidoc/testing.adoc b/src/docs/asciidoc/testing.adoc
index 567961bf1f08..c5f4aae0807c 100644
--- a/src/docs/asciidoc/testing.adoc
+++ b/src/docs/asciidoc/testing.adoc
@@ -5056,7 +5056,7 @@ hierarchy runs within a transaction. Test methods that are not annotated with
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` attribute set to
-`NOT_SUPPORTED` are not run within a transaction.
+`NOT_SUPPORTED` or `NEVER` are not run within a transaction.
[[testcontext-tx-attribute-support]]
.`@Transactional` attribute support
@@ -5065,7 +5065,7 @@ are annotated with `@Transactional` but have the `propagation` attribute set to
|`value` and `transactionManager` |yes
-|`propagation` |only `Propagation.NOT_SUPPORTED` is supported
+|`propagation` |only `Propagation.NOT_SUPPORTED` and `Propagation.NEVER` are supported
|`isolation` |no