title: Spring boot multi module testing
body: <p>My question is regarding testing a multi-module Spring boot application.</p>
  
  <p>I have a multi-module spring boot REST application. The application is structured as follows:</p>
  
  <pre><code>**SpringbootMainApplication
  --src/main/java
    --org.test
         +Springbootapplicationinitializer.java //Annotated with @SpringBootApplication
    --org.test.controller
    --org.test.service
    --org.test.dao
  SpringbootModule
  --src/main/java
     --org.module
          +SpringModuleInitializer.java //Annotated with @SpringBootApplication
     --org.module.controller
     --org.module.service
     --org.module.dao**
  </code></pre>
  
  <p>The above is how my application is structured.</p>
  
  <p>SpringBootMainApplication is the main project. SpringbootModule is the subproject inside SpringBootMainApplication. "SpringBootMainApplication.war" WAR will be built with "SpringbootModule.jar" inside the WAR.</p>
  
  <p>I have separate test cases for both these projects. I want to make these projects individually testable. 
  By this I mean, my test cases for SpringBootMainApplication while performing the test cases should use "Springbootapplicationinitializer.java" and my test cases for SpringBootModule while performing the test cases should use "SpringModuleinitializer.java". But when it is packaged as a WAR and
   the SpringModuleInitializer.java should not come into play or should have no bearing. </p>
  
  <p>Is there any way by which I can achieve this? Or should I completely avoid SpringModuleInitializer.java, perform only unit tests in the module and do integration testing only using Springbootapplicationinitializer.java.</p>
  
  <p>If it is of any help, I am using gradle for build and packaging.</p>