0

I was trying to run some sql scripts before my Spring-boot integration tests,

I refered this solution and placed my sql script at the root level in resources folder (i.e. src/integrationTest/resources)

Cucumber Test stepDef class src/integrationTest/java/steps/StepDefinitions.java

@Sql(scripts = "clean-up.sql", executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD)
public class StepDefinitions {

..

clean-up.sql

delete from my_table where id in ('FOP678A090839984D04BA76E07DEB7C58BC', 'FOP678A090839984D04BA76E07DEB7C5811');
commit;

However nothing deleted from my PostgreSQL after running Spring-boot integration tests

2
  • 1
    You should put the @Sql annotation on the @CucumberSpringContext annotated class. Upgrade Cucumber if you don't have that annotation. Commented Dec 17, 2023 at 12:18
  • @M.P.Korstanje Yep, that works !!! and need to add classpath like @Sql(scripts = "classpath:clean-up.sql"... to add the file in integrationTest resources folder. Commented Dec 17, 2023 at 23:58

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.