You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: framework-docs/modules/ROOT/pages/testing/testcontext-framework/executing-sql.adoc
+67-7Lines changed: 67 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -95,13 +95,22 @@ In addition to the aforementioned mechanisms for running SQL scripts programmati
95
95
you can declaratively configure SQL scripts in the Spring TestContext Framework.
96
96
Specifically, you can declare the `@Sql` annotation on a test class or test method to
97
97
configure individual SQL statements or the resource paths to SQL scripts that should be
98
-
run against a given database before or after an integration test method. Support for
99
-
`@Sql` is provided by the `SqlScriptsTestExecutionListener`, which is enabled by default.
100
-
101
-
NOTE: Method-level `@Sql` declarations override class-level declarations by default. As
102
-
of Spring Framework 5.2, however, this behavior may be configured per test class or per
103
-
test method via `@SqlMergeMode`. See
104
-
xref:testing/testcontext-framework/executing-sql.adoc#testcontext-executing-sql-declaratively-script-merging[Merging and Overriding Configuration with `@SqlMergeMode`] for further details.
98
+
run against a given database before or after an integration test class or test method.
99
+
Support for `@Sql` is provided by the `SqlScriptsTestExecutionListener`, which is enabled
100
+
by default.
101
+
102
+
[NOTE]
103
+
====
104
+
Method-level `@Sql` declarations override class-level declarations by default, but this
105
+
behavior may be configured per test class or per test method via `@SqlMergeMode`. See
106
+
xref:testing/testcontext-framework/executing-sql.adoc#testcontext-executing-sql-declaratively-script-merging[Merging and Overriding Configuration with `@SqlMergeMode`]
107
+
for further details.
108
+
109
+
However, this does not apply to class-level declarations configured for the
110
+
`BEFORE_TEST_CLASS` or `AFTER_TEST_CLASS` execution phases. Such declarations cannot be
111
+
overridden, and the corresponding scripts and statements will be executed once per class
112
+
in addition to any method-level scripts and statements.
0 commit comments