diff --git a/spring-test/src/main/java/org/springframework/test/context/transaction/TestContextTransactionUtils.java b/spring-test/src/main/java/org/springframework/test/context/transaction/TestContextTransactionUtils.java index 2945ea14b0..01c55a1535 100644 --- a/spring-test/src/main/java/org/springframework/test/context/transaction/TestContextTransactionUtils.java +++ b/spring-test/src/main/java/org/springframework/test/context/transaction/TestContextTransactionUtils.java @@ -35,7 +35,6 @@ import org.springframework.transaction.annotation.TransactionManagementConfigure import org.springframework.transaction.interceptor.DelegatingTransactionAttribute; import org.springframework.transaction.interceptor.TransactionAttribute; import org.springframework.util.Assert; -import org.springframework.util.ClassUtils; import org.springframework.util.StringUtils; /** @@ -270,12 +269,11 @@ public abstract class TestContextTransactionUtils { super(targetAttribute); + String name = testContext.getTestClass().getName(); if (includeMethodName) { - this.name = ClassUtils.getQualifiedMethodName(testContext.getTestMethod(), testContext.getTestClass()); - } - else { - this.name = testContext.getTestClass().getName(); + name += "." + testContext.getTestMethod().getName(); } + this.name = name; } @Override diff --git a/spring-test/src/test/java/org/springframework/test/context/jdbc/SqlScriptsTestExecutionListenerTests.java b/spring-test/src/test/java/org/springframework/test/context/jdbc/SqlScriptsTestExecutionListenerTests.java index 07b3abd10c..689701970f 100644 --- a/spring-test/src/test/java/org/springframework/test/context/jdbc/SqlScriptsTestExecutionListenerTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/jdbc/SqlScriptsTestExecutionListenerTests.java @@ -116,6 +116,9 @@ class SqlScriptsTestExecutionListenerTests { assertThatIllegalArgumentException() .isThrownBy(() -> listener.beforeTestMethod(testContext)) .withMessage("@SQL execution phase BEFORE_TEST_CLASS cannot be used on methods"); + assertThatIllegalArgumentException() + .isThrownBy(() -> listener.afterTestMethod(testContext)) + .withMessage("@SQL execution phase BEFORE_TEST_CLASS cannot be used on methods"); } @Test @@ -127,6 +130,9 @@ class SqlScriptsTestExecutionListenerTests { assertThatIllegalArgumentException() .isThrownBy(() -> listener.beforeTestMethod(testContext)) .withMessage("@SQL execution phase AFTER_TEST_CLASS cannot be used on methods"); + assertThatIllegalArgumentException() + .isThrownBy(() -> listener.afterTestMethod(testContext)) + .withMessage("@SQL execution phase AFTER_TEST_CLASS cannot be used on methods"); } private void assertExceptionContains(String msg) throws Exception {