Skip to content

Add mechanism to disable inherited @Sql class-level execution phase scripts/statements in @Nested test class #31378

Open

Description

@sbrannen

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.

Activity

  1. added this to the 6.1.0-RC2 milestone on Oct 8, 2023
  2. self-assigned this
    on Oct 8, 2023
  3. sbrannen commented on Oct 8, 2023

    @sbrannen
    MemberAuthor

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

  4. aahlenst commented on Oct 10, 2023

    @aahlenst
    Contributor

    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?

  5. modified the milestones: 6.1.0-RC2, 6.1.x on Oct 25, 2023
  6. modified the milestones: 6.1.x, 6.2.x on Dec 18, 2023
  7. 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
  8. 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
  9. modified the milestones: 6.2.x, 6.2.0-M1, 6.2.0-M2 on Mar 18, 2024
  10. modified the milestones: 6.2.0-M2, 6.2.x on May 12, 2024
  11. modified the milestones: 6.2.x, 7.0.x on Oct 19, 2024
  12. modified the milestones: 7.0.x, 7.x on Oct 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions