为你的maven项目加上测试覆盖率报告。

这里使用 maven clover plugin, 在你的pom.xml中加上以下的代码。

     
<plugin>
        <groupId>com.atlassian.maven.plugins</groupId>
        <artifactId>maven-clover2-plugin</artifactId>

        <configuration>
			<!--includesTestSourceRoots>false</includesTestSourceRoots-->
          <targetPercentage>1%</targetPercentage>

          <!-- Verify that we can specify the JDK version for Clover's instrumentation -->
          <jdk>1.6</jdk>

          <!-- Verify that we can exclude some files from the instrumentation. Make sure the file we are excluding
               is referenced by other classes to ensure excluding is only done at the Clover level -->
          <excludes>

            <exclude>**/*Dummy*.java</exclude>
          </excludes>

             <licenseLocation>${clover.licenseLocation}</licenseLocation>
        </configuration>
        <executions>
          <execution>
            <id>main</id>

            <phase>verify</phase>
            <goals>
              <goal>instrument</goal>
              <goal>check</goal>
            </goals>
          </execution>
          <execution>

            <id>site</id>
            <phase>pre-site</phase>
            <goals>
              <goal>instrument</goal>
            </goals>
          </execution>
        </executions>

      </plugin>


  <reporting>
    <excludeDefaults>true</excludeDefaults>
    <plugins>
      <plugin>
        <groupId>com.atlassian.maven.plugins</groupId>

        <artifactId>maven-clover2-plugin</artifactId>
        <configuration>

          <!-- Verify that we can modify the location of the Clover database and that the directory is created if
               it doesn't exist. Note: we're putting the configuration here and not in the build section because the
               build section inherits from the reporting section but not the other way around... -->
          <!--cloverDatabase>${project.build.directory}/customclover/myclover.db</cloverDatabase-->

          <!-- Verify that we can generate all types of Clover reports -->
          <generateHtml>true</generateHtml>
          <generatePdf>true</generatePdf>

          <generateXml>true</generateXml>

          <!-- We ask the Clover plugin to generate a historical report but we don't have any historical data saved.
               This is to verify it doesn't error out when this is the case. -->
          <generateHistorical>true</generateHistorical>
             <licenseLocation>${clover.licenseLocation}</licenseLocation>
	  <!--useFullyQualifiedJavaLang>false</useFullyQualifiedJavaLang-->
        </configuration>
      </plugin>

    </plugins>
  </reporting>

 
然后运行 mvn install 和 mvn site 就行了。 当然其中会有一些这个maven插件的配置。 具体请看http://docs.atlassian.com/maven-clover2-plugin/2.3.1/usage.html

你可能感兴趣的:(jdk,html,maven,xml)