如何在SONAR分析中包含JUnit测试

时间:2015-04-29 12:53:33

标签: maven testing sonarqube

我使用sonarqube-5.0.1来管理代码质量和maven作为构建工具。当我运行mvn声纳:声纳时,它并没有考虑用于分析的测试类。如何在声纳中包含要分析的测试类。

我的pom.xml在下面给出

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>X.X.X</modelVersion>
<groupId>com.XXXXXX.XXXXX</groupId>
<artifactId>XXXX-XXXXXX</artifactId>
<version>X.X.X</version>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>1.7</maven.compiler.source>
    <maven.compiler.target>1.7</maven.compiler.target>
    <slf4j.version>1.6.1</slf4j.version>
    <suiteXmlFile>src/test/resources/junit.xml</suiteXmlFile>
    <maven.source.classifier>src</maven.source.classifier>
    <maven.source.test.classifier>tests-src</maven.source.test.classifier>
</properties>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.18.1</version>
            <configuration>
                <suiteXmlFiles>
                    <suiteXmlFile>${suiteXmlFile}</suiteXmlFile>
                </suiteXmlFiles>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-project-info-reports-plugin</artifactId>
            <version>2.7</version>              
        </plugin>

        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>cobertura-maven-plugin</artifactId>
            <version>2.6</version>
            <configuration>
                <formats>
                    <format>html</format>
                    <format>xml</format>
                </formats>
            </configuration>
        </plugin>

        <!-- Make Jars -->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <version>2.6</version>
            <configuration>
                <excludes>
                    <exclude>**/*.properties</exclude>
                    <exclude>**/*.txt</exclude>
                    <exclude>**/*.xml</exclude>
                    <exclude>**/*.xsd</exclude>
                    <exclude>**/*schema*</exclude>
                </excludes>
                <archive>
                    <manifest>
                        <addClasspath>true</addClasspath>
                        <classpathPrefix>dependency-jars/</classpathPrefix>
                    </manifest>
                    <addMavenDescriptor>false</addMavenDescriptor>
                </archive>
            </configuration>
            <executions>
                <execution>
                    <goals>
                        <goal>jar</goal>
                        <goal>test-jar</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        <!-- Make Source jar -->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-source-plugin</artifactId>
            <version>2.4</version>
            <configuration>
                <excludes>
                    <exclude>**/*.properties</exclude>
                    <exclude>**/*.txt</exclude>
                    <exclude>**/*.xml</exclude>
                    <exclude>**/*.xsd</exclude>
                    <exclude>**/*schema*</exclude>
                </excludes>
                <includePom>true</includePom>
            </configuration>
            <executions>
                <execution>
                    <goals>
                        <goal>jar</goal>
                        <goal>test-jar</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        <!-- Make Source Javadocs -->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-javadoc-plugin</artifactId>
            <version>2.10.2</version>
            <configuration>
              <show>private</show>
              <reportOutputDirectory>${project.basedir}/docs</reportOutputDirectory>
            </configuration>
        </plugin>
    </plugins>
</build>
<!-- Generate Reports Summary Note: dependency management reports are excluded-->
<reporting>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-project-info-reports-plugin</artifactId>
            <version>2.7</version>
            <configuration>
                <dependencyDetailsEnabled>false</dependencyDetailsEnabled>
                <dependencyLocationsEnabled>false</dependencyLocationsEnabled>
            </configuration>
            <reportSets>
                <reportSet>
                    <reports>
                        <report>cim</report>
                        <report>distribution-management</report>
                        <report>index</report>
                        <report>issue-tracking</report>
                        <report>license</report>
                        <report>mailing-list</report>
                        <report>modules</report>
                        <report>plugin-management</report>
                        <report>plugins</report>
                        <report>project-team</report>
                        <report>scm</report>
                        <report>summary</report>
                    </reports>
                </reportSet>
            </reportSets>
        </plugin>
    </plugins>
</reporting>
<dependencies>
    <dependency>
        <groupId>org.apache.hadoop</groupId>
        <artifactId>hadoop-common</artifactId>
        <version>2.6.0</version>
    </dependency>
    <dependency>
        <groupId>org.apache.hadoop</groupId>
        <artifactId>hadoop-hdfs</artifactId>
        <version>2.6.0</version>
    </dependency>
    <dependency>
        <groupId>org.apache.hbase</groupId>
        <artifactId>hbase-hadoop-compat</artifactId>
        <version>0.98.9-hadoop2</version>
        <type>test-jar</type>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.apache.hbase</groupId>
        <artifactId>hbase-hadoop2-compat</artifactId>
        <version>0.98.9-hadoop2</version>
        <type>test-jar</type>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.apache.hbase</groupId>
        <artifactId>hbase-server</artifactId>
        <version>0.98.9-hadoop2</version>
        <type>test-jar</type>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.apache.hbase</groupId>
        <artifactId>hbase-common</artifactId>
        <version>0.98.9-hadoop2</version>
        <type>test-jar</type>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.apache.hbase</groupId>
        <artifactId>hbase-server</artifactId>
        <type>jar</type>
        <version>0.98.9-hadoop2</version>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.apache.hbase</groupId>
        <artifactId>hbase-client</artifactId>
        <version>0.98.9-hadoop2</version>
    </dependency>
    <dependency>
        <groupId>jdk.tools</groupId>
        <artifactId>jdk.tools</artifactId>
        <systemPath>${env.JAVA_HOME}/lib/tools.jar</systemPath>
        <scope>system</scope>
        <version>1.7</version>
    </dependency>

    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.12</version>
    </dependency>

    <dependency>
        <groupId>org.testng</groupId>
        <artifactId>testng</artifactId>
        <version>6.8.8</version>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.powermock</groupId>
        <artifactId>powermock-module-junit4</artifactId>
        <version>1.6.2</version>
    </dependency>

    <dependency>
        <groupId>org.powermock</groupId>
        <artifactId>powermock-api-mockito</artifactId>
        <version>1.6.2</version>
    </dependency>
</dependencies>

0 个答案:

没有答案