urbanq opened SPR-14357 and commented

It would be helpful to introduce class-level support in the ExecutionPhase enum used by @Sql: BEFORE_CLASS and AFTER_CLASS.

So when executing integration test we can easily run one single SQL script for all test methods in the test class.


Affects: 4.2.6

Reference URL: https://stackoverflow.com/questions/32871817/using-annotation-sql-is-it-possible-to-execute-scripts-in-class-level-before-m

Issue Links: - #20570 Introduce opt-in support for merging class-level and method-level @Sql declarations

4 votes, 5 watchers

Comment From: spring-projects-issues

Semukhin Dmitry commented

Proposal

Introduce additional BEFORE_TEST_CLASS and AFTER_TEST_CLASS enum constants in Sql.ExecutionPhase and override the beforeTestClass() and afterTestClass() methods in SqlScriptsTestExecutionListener with corresponding invocations of executeSqlScripts(...) - for example:

public void beforeTestClass(TestContext testContext) throws Exception {
    executeSqlScripts(testContext, ExecutionPhase.BEFORE_TEST_CLASS);
}

The implementation of afterTestClass() would be analogous to the above.

Sam Brannen, please share your thoughts on the plan if you have time for that.

Comment From: spring-projects-issues

Semukhin Dmitry commented

Actually issue #20570 should be marked not as "relates to" but rather "blocked by"

Comment From: spring-projects-issues

Sam Brannen commented

In what way do you foresee that it is blocked?

Comment From: spring-projects-issues

Sam Brannen commented

FYI: I took the liberty to edit your comments/proposal.

Comment From: spring-projects-issues

Sam Brannen commented

Sam Brannen, please share your thoughts on the plan if you have time for that.

I think the general idea sounds fine.

The main issue I see is coming up with a compelling story for implementing both #20570 and #18929, and if we implement both we will then need to test use cases that combine the two (i.e., in order to verify that they work together in harmony and whether or not it makes sense to implement both).

So I would appreciate it if you could document that story as you see it.

Comment From: aahlenst

@sbrannen I opened #27285 to get the ball rolling. Please let me know what you think and what I could do to improve the PR (like adding more tests).

Comment From: juzunoglu

Is this still being implemented?

Comment From: sbrannen

  • superseded by #27285