【发布时间】:2011-07-26 01:07:06
【问题描述】:
我正在使用声纳 2.6 和 maven 3
我正在使用默认的 corbetura 插件来覆盖我的项目的代码,但它始终显示 0% 的覆盖率,尽管我使用 junit-4.9b2.jar 编写了 junit 测试用例
这是我的 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>4.0.0</modelVersion>
<groupId>com.niit.karan</groupId>
<artifactId>DataBlast</artifactId>
<name>DataBlast</name>
<version>1.0</version>
<build>
<sourceDirectory>src</sourceDirectory>
<outputDirectory>bin</outputDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<excludes>
<exclude>**/*.*</exclude>
</excludes>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.3</version>
<configuration>
<forkMode>once</forkMode>
<instrumentation>
<ignores>
<ignore>com.example.boringcode.*</ignore>
</ignores>
<excludes>
<exclude>com/example/dullcode/**/*.class</exclude>
<exclude>com/example/**/*Test.class</exclude>
</excludes>
</instrumentation>
</configuration>
<executions>
<execution>
<goals>
<goal>clean</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>2.0-beta-2</version>
<configuration>
<timeout>3600000</timeout>
</configuration>
</plugin>
</plugins>
</build>
<properties>
<sonar.dynamicAnalysis>true</sonar.dynamicAnalysis>
</properties>
</project>
这是我为检查插件而编写的测试用例:
package test;
import junit.framework.TestCase;
public class TestCalc extends TestCase{
Calc calc = new Calc();
public void testSum(){
assertTrue(3 == calc.sum(1, 2));
assertTrue(4 == calc.sum(2, 2));
}
}
请有人帮忙考虑一下我是声纳的新用户。在此先感谢
【问题讨论】:
-
不告诉您究竟您已经尝试过什么,或者您的
pom.xml中的一个sn-p,很难为您提供帮助。请提供更多信息。 -
Sonar 使用自己的 cobertura 插件。您可以发布调用插件的声纳日志的相关部分 - 如果有的话
-
我已经包含了 sn-ps 请帮助...