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 b98b9999973637f72ee7734a9369db97ee3344a3 and d1b43386b1bc23f87a3cfd0e5de5a3d6ca23f4cb 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.

Comment From: sbrannen

@aahlenst, had you put any thought into accidental inheritance of class-level execution phase scripts/statements while working on #27285?

Comment From: aahlenst

Unfortunately not. I missed that @Nested would be impacted by that change. Otherwise, I would have at least mentioned it. Thanks for noticing.

We may need to introduce some form of boolean inheritClassLevelExecutionPhases flag.

Do you intend to add that flag to @SqlMergeMode?