spring - Using annotation @Sql, is it possible to execute scripts in Class level before Method level? -


i want execute 2 scripts before every test method, want define scripts execute before specific methods. using spring framework , @sql annotations, possible?

@runwith(springjunit4classrunner.class) @contextconfiguration("/web-inf/application-context.xml") @dirtiescontext(classmode = classmode.before_each_test_method) @sql({ "/database/drop_schema.sql", "/database/create_schema.sql" }) public class centralservicetestcase {    // want run "drop_schema.sql", "create_schema.sql"    // , "basic_data.sql" here   @test   @sql({ "/database/basic_data.sql" })          public void processactionwithsuccess() {    }    // want run "drop_schema.sql" , "create_schema.sql" here   @test    public void anothertestmethod() {    }  } 

running code "basic_data.sql" executed. how solve problem? have remove @sql anotation class , replicate each method "/database/drop_schema.sql" , "/database/create_schema.sql" defined?

update: may potentially addressed in spr-14357.


the 2nd paragraph of javadoc @sql explicitly states:

method-level declarations override class-level declarations.

this documented in executing sql scripts declaratively @sql section of reference manual.

thus, no, unfortunately not possible have scripts declared via @sql @ class level executed if @sql defined @ method level.

if spring support such combinations, please create jira issue requesting feature , select test component.

thanks!

sam (author of spring testcontext framework)


Comments

Popular posts from this blog

1111. appearing after print sequence - php -

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

Ruby on Rails, ActiveRecord, Postgres, UTF-8 and ASCII-8BIT encodings -