maven - Sonar: measuring code coverage when integration tests are in a different project -


having following maven project structure:

-project1          <-- parent pom 2 children. |--module1         <-- web services \--module1-itest   <-- integration tests written testng 

what today:

  • run mvn sonar:sonar in module1, shows code coverage unit tests in sonar's dashboard.
  • run mvn jetty:run on module1, , after run mvn test on module1-itests test it.

i know far ideal scenario... it's more intermediate step while try improve legacy project no tests @ all...


my question is: best way code coverage done execution of integration tests in sonar's dashboard of module1?

initially, i'm inclined move code in module1-itest module1, , run them using failsafe plugin , well-documented integration jacoco. in way, module1 have mix of junit unit tests , testng integration tests, each group run surefire , failsafe, respectively, starting jetty server in pre-integration phase.

however, have reasons keep both projects separated, i'm wondering:

  1. is approach above one?
  2. is there other recommended way can use keep both projects separated, including code coverage done module1-itest in module1 sonar's dashboard?

thanks,

this how solved it:

summary:

  • service , service-itest projects 2 independent modules.
  • service has unit tests coverage reported sonar.
  • service-itests uses cargo load service war , run integration tests. code coverage collected in execution reported 1 level above. in way, coverage itests collected , merged cross-module , reported @ parent project pom level. approach becasue allows have different itests projects (for example, 1 cargo loading app , using jbehave), , can evolve independently.

in parent pom:

    <modules>             <module>service</module>             <module></module>             <module>service-itest</module>         </modules>     <!-- sonar -->             <sonar.java.coverageplugin>jacoco</sonar.java.coverageplugin>             <sonar.dynamicanalysis>reusereports</sonar.dynamicanalysis>             <!-- destination file code coverage report has set                  same value in parent pom , in each module pom. jacoco                  add information in same report, that, give cross-module                  code coverage. -->             <sonar.jacoco.itreportpath>${project.basedir}/../target/jacoco-itests.exec</sonar.jacoco.itreportpath> ... <build>         <pluginmanagement>             <plugins>                 <plugin>                     <groupid>org.jacoco</groupid>                     <artifactid>jacoco-maven-plugin</artifactid>                     <version>0.6.3.201306030806</version>                 </plugin>             </plugins>         </pluginmanagement> ... <plugin>                 <groupid>org.jacoco</groupid>                 <artifactid>jacoco-maven-plugin</artifactid>                 <configuration>                     <includes>                         <include>our.project.packages.*</include>                     </includes>                 </configuration>                 <executions>                     <execution>                         <id>pre-test</id>                         <goals>                             <goal>prepare-agent</goal>                         </goals>                     </execution>                     <execution>                         <id>post-test</id>                         <phase>test</phase>                         <goals>                             <goal>report</goal>                         </goals>                     </execution>                 </executions>             </plugin> 

and in pom.xml file of -itest project:

<plugin>                 <groupid>org.jacoco</groupid>                 <artifactid>jacoco-maven-plugin</artifactid>                 <configuration>                     <!-- destination file code coverage report has set                          same value in parent pom , in each module pom. jacoco                          add information in same report, that, give cross-module                          code coverage. -->                     <destfile>${project.basedir}/../target/jacoco-itests.exec</destfile>                     <includes>                         <include>our.packages.*</include>                     </includes>                 </configuration>                 <executions>                     <execution>                         <id>post-test</id>                         <configuration>                             <skip>true</skip>                         </configuration>                     </execution>                 </executions>             </plugin>             <plugin>                 <groupid>org.codehaus.cargo</groupid>                 <artifactid>cargo-maven2-plugin</artifactid>                 <version>1.2.2</version>                 <configuration>                     <skip>${cargo.skip}</skip>                     <container>                         <containerid>jetty7x</containerid>                         <artifactinstaller>                             <groupid>org.eclipse.jetty</groupid>                             <artifactid>jetty-distribution</artifactid>                             <version>7.6.12.v20130726</version>                             <type>zip</type>                         </artifactinstaller>                     </container>                     <configuration>                         <type>standalone</type>                         <properties>                             <cargo.servlet.port>${jetty.port}</cargo.servlet.port>                             <cargo.jvmargs>${argline}</cargo.jvmargs>                         </properties>                         <deployables>                             <deployable>                                 <artifactid>pam_filetask_manager_service</artifactid>                                 <groupid>${project.groupid}</groupid>                                 <type>war</type>                                 <pingurl>http://server:22000/ping</pingurl>                                 <properties>                                 </properties>                             </deployable>                         </deployables>                     </configuration>                 </configuration>                 <executions>                     <execution>                         <id>start-server</id>                         <phase>pre-integration-test</phase>                         <goals>                             <goal>install</goal>                             <goal>start</goal>                         </goals>                     </execution>                     <execution>                         <id>stop-server</id>                         <phase>post-integration-test</phase>                         <goals>                             <goal>stop</goal>                         </goals>                     </execution>                 </executions>             </plugin> 

Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -