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
{{ message }}
Repository navigation
Add mechanism to disable inherited @Sql class-level execution phase scripts/statements in @Nested test class #31378
This is a follow-up to #27285 to ensure that users can "disable" class-level execution phase scripts and statements that would otherwise be inherited in a @Nested test class.
Commits b98b999 and d1b4338 introduced tests for the status quo for @Sql scripts/statements inherited from the enclosing class of a @Nested test class.
Those tests pass; however, if you change "recreate-schema.sql" to "schema.sql" in the class-level @Sql declarations on those enclosing test classes, the @Nested test classes will then fail since the class-level execution phase scripts/statements are executed for the enclosing class and then again for each @Nested class, which is probably not what the user intends.
Method-level @Sql declarations can already be configured to override or merge with class-level @Sql declarations via @SqlMergeMode. So we might be able to "disable" class-level execution phase scripts and statements by introducing additional enum constants in SqlMergeMode.MergeMode, or we may need to introduce some form of boolean inheritClassLevelExecutionPhases flag.
In summary, I think we need a way for a @Nested test class (or a subclass of a test class) to disable inheritance of class-level execution phase scripts/statements, but the nature of how this will be "disabled" is yet to be determined.
changed the title [-]Add mechanism to disable inherited `@Sql` class-level execution phase scripts/statements in `@Nested` test class[/-][+]Add mechanism to disable inherited @Sql class-level execution phase scripts/statements in @Nested test class[/+]on Feb 14, 2024
changed the title [-]Add mechanism to disable inherited @Sql class-level execution phase scripts/statements in @Nested test class[/-][+]Add mechanism to disable inherited `@Sql` class-level execution phase scripts/statements in `@Nested` test class[/+]on Feb 14, 2024
Activity
sbrannen commentedon Oct 8, 2023
@aahlenst, had you put any thought into accidental inheritance of class-level execution phase scripts/statements while working on #27285?
aahlenst commentedon Oct 10, 2023
Unfortunately not. I missed that
@Nestedwould be impacted by that change. Otherwise, I would have at least mentioned it. Thanks for noticing.Do you intend to add that flag to
@SqlMergeMode?[-]Add mechanism to disable inherited `@Sql` class-level execution phase scripts/statements in `@Nested` test class[/-][+]Add mechanism to disable inherited @Sql class-level execution phase scripts/statements in @Nested test class[/+][-]Add mechanism to disable inherited @Sql class-level execution phase scripts/statements in @Nested test class[/-][+]Add mechanism to disable inherited `@Sql` class-level execution phase scripts/statements in `@Nested` test class[/+]