Rahul Sharma Rahul Sharma - 2 months ago 10
Java Question

Merging @Sql from superclass with @Sql in subclass

I have an abstract class annotated with

@Sql(executionPhase = ExecutionPhase.BEFORE_TEST_METHOD, scripts="someScript")
.

I have a test class which inherits from the abstract class. The child class is also annotated with
@Sql(executionPhase = ExecutionPhase.BEFORE_TEST_METHOD, scripts="someOtherScript")
.

When I was running spring boot 1.2, everything worked as I expected it to: scripts from parent class were run before child class. I upgraded to spring boot 1.3 and now, the child class's
@Sql
overrides parent class's
@Sql
and the parent class scripts are never run.

With spring boot 1.3 is there a different way of doing this? So that parent class scripts are run before child class scripts?

Answer

After @SamBrannen's answer, I ended up running the script from child class using ScriptUtils.execute method.

Comments