Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

code coverage for junit plug-in tests with maven

Below is my maste pom file profile for my product unit tests. we have junit plug-in tests. These pom file configurations not giving me the jacoco code coverage file(.exec) in any location. please help me if any wrong some where. Thank you

    <profile>
        <id>unit-tests</id>
        <modules>
            <module>../../../test/com.xxxx.tools.comms.test.utilities</module>

            <!-- product related unit tests 
            <module>../../../test/com.xxxx.comms.product.test</module>
            <module>../../../test/com.xxxx.comms.product.mas.test</module>-->
            <module>../../../test/com.xxxx.comms.product.iv.test</module> 
        </modules>

        <properties>
            <!-- Properties to enable jacoco code coverage analysis -->
            <sonar.core.codeCoveragePlugin>jacoco</sonar.core.codeCoveragePlugin>
            <sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
        </properties>

        <build>
            <plugins>
                <plugin>
                    <groupId>org.jacoco</groupId>
                    <artifactId>jacoco-maven-plugin</artifactId>
                    <version>0.7.2.201409121644</version>
                    <configuration>
                        <!-- Where to put jacoco coverage report -->
                        <destFile>C:/Userdata/product/GIT/Team/coverage/product1/jacoco/12.exec</destFile>
                    </configuration>
                    <executions>
                        <execution>
                            <id>jacoco-initialize</id>
                            <goals>
                                <goal>prepare-agent</goal>
                            </goals>

                        </execution>
                        <execution>
                            <id>jacoco-site</id>
                            <phase>package</phase>
                            <goals>
                                <goal>report</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>
    </profile>


<build>
        <plugins>
            <!-- Use of Tycho -->
            <plugin>
                <groupId>org.eclipse.tycho</groupId>
                <artifactId>tycho-maven-plugin</artifactId>
                <version>${tycho-version}</version>
                <extensions>true</extensions>
            </plugin>

            <plugin>
                <groupId>org.eclipse.tycho</groupId>
                <artifactId>tycho-surefire-plugin</artifactId>
                <version>${tycho-version}</version>
                <configuration>
                    <includes>
                        <include>**/Tests*.java,**/*Tests.java,**/*TestCase.java,**/Test*.java,**/*Test.java</include>
                    </includes>
                    <argLine>${argLine}</argLine>
                    <useUIHarness>true</useUIHarness>
                    <!-- Kill test JVM if tests take more than 1 minute to finish -->
                    <forkedProcessTimeoutInSeconds>600</forkedProcessTimeoutInSeconds>
                    <testFailureIgnore>true</testFailureIgnore>
                </configuration>

            </plugin>

            <!-- Configuration of target platforms -->
            <plugin>
                <groupId>org.eclipse.tycho</groupId>
                <artifactId>target-platform-configuration</artifactId>
                <version>${tycho-version}</version>
                <configuration>
                    <pomDependencies>consider</pomDependencies>
                    <resolver>p2</resolver>
                    <environments>
                        <environment>
                            <os>win32</os>
                            <ws>win32</ws>
                            <arch>x86</arch>
                        </environment>
                    </environments>
                </configuration>
            </plugin>

        </plugins>

        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.eclipse.tycho</groupId>
                    <artifactId>tycho-packaging-plugin</artifactId>
                    <version>${tycho-version}</version>
                    <configuration>
                        <!-- workaround for TYCHO-349 or TYCHO-313 -->
                        <strictVersions>false</strictVersions>
                    </configuration>
                </plugin>

                <plugin>
                    <groupId>org.eclipse.tycho</groupId>
                    <artifactId>tycho-compiler-plugin</artifactId>
                    <version>${tycho-version}</version>
                    <configuration>
                        <source>${jdk.version}</source>
                        <target>${jdk.version}</target>
                    </configuration>
                </plugin>

            </plugins>
        </pluginManagement>
    </build>
like image 642
Ashok K Avatar asked Jul 07 '15 06:07

Ashok K


1 Answers

I got the problem source.
The culprit is <argLine> parameter in tycho-surefire-plugin configuration.
If this param is present, jacoco file is not generated. I removed it and now .exec file is generated.
More info found at tycho-surefire argLine causes no jacaco.exec

like image 167
Ashok K Avatar answered Oct 23 '22 13:10

Ashok K