spring - Run another project's web service before start tests -


intellij project has 2 modules: spring data rest app , client. both apps spring bootable apps. made lot of tests @ client , before every test iteration have run rest service manually. test class looks that:

@runwith(springjunit4classrunner.class) @contextconfiguration(classes = {businessrepositoryimpl.class}) public class businesslogorepositorytest { .. } 

here service:

@enableautoconfiguration @importresource({         "classpath:spring/persistencecontext.xml" }) @import(dataserviceconfiguration.class) public class application {      public static void main(string[] args) throws exception {         springapplication.run(application.class, args);     } } 

so question if it's possible somehow add context of service test class , run service before test's start.

you can create testsuite 2 methods annotated @beforeclass , @afterclass start service before tests , stop after tests done.

draft code visualize :) mean below.

@runwith(springjunit4classrunner.class) @suiteclasses({unittest1.class, unittest2.class, ... })  @enableautoconfiguration @importresource({     "classpath:spring/persistencecontext.xml" }) @import(dataserviceconfiguration.class)  public class testsuite {      @beforeclass     public void start() throws exception {         springapplication.run(application.class, args);     }      @afterclass     public void start() throws exception {         springapplication.shutdown();     } } 

Comments