【发布时间】:2012-09-10 14:30:51
【问题描述】:
情况
我试图让 Sonar 显示由 FlexUnit 从使用 Flex-Mojos 的 Maven 构建作业生成的代码覆盖率报告,但我没有任何运气 - 我得到的只是一个令人沮丧的“-” .
构建输出
结果是仪表板总是显示这个(左列): (不,单元测试不会运行超过 90 分钟,而是 16 秒;不知道这里发生了什么)
Sonar 相关的控制台输出是这样的: 所以一切似乎都运行良好(除了 Cobertura 之外没有找不到文件的错误,我似乎无法以任何方式摆脱它,没有解析异常等)。
构建设置
用于构建项目的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>
<parent>
<groupId>foo</groupId>
<artifactId>parent</artifactId>
<version>1.0.3</version>
</parent>
<groupId>foo</groupId>
<artifactId>bar</artifactId>
<version>0.1.0-SNAPSHOT</version>
<packaging>swc</packaging>
<name>Bar</name>
<dependencies>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito</artifactId>
<version>1.4M5</version>
<type>swc</type>
<scope>external</scope>
</dependency>
<dependency>
<groupId>com.adobe.flexunit</groupId>
<artifactId>flexunit</artifactId>
<version>4.1.0-8</version>
<classifier>flex</classifier>
<type>swc</type>
<scope>external</scope>
</dependency>
</dependencies>
<build>
<testSourceDirectory>src/test/flash</testSourceDirectory>
<plugins>
<plugin>
<groupId>org.sonatype.flexmojos</groupId>
<artifactId>flexmojos-maven-plugin</artifactId>
<version>4.2-beta</version>
<configuration>
<coverage>true</coverage>
<debug>false</debug>
<optimize>true</optimize>
<omitTraceStatements>true</omitTraceStatements>
<verboseStacktraces>false</verboseStacktraces>
<defines>
<property>
<name>CONFIG::BUILD</name>
<value>"${project.version}"</value>
</property>
</defines>
</configuration>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>asdoc</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
<resources>
<resource>
<directory>${project.build.directory}/asdoc/tempdita</directory>
<targetPath>docs</targetPath>
<includes>
<include>**/*.xml</include>
</includes>
<excludes>
<exclude>ASDoc_Config.xml</exclude>
<exclude>overviews.xml</exclude>
</excludes>
</resource>
</resources>
</build>
<properties>
<sonar.language>flex</sonar.language>
<sonar.sources>src/main/flash</sonar.sources>
<sonar.tests>src/test/flash</sonar.tests>
<sonar.surefire.reportsPath>target/surefire-reports</sonar.surefire.reportsPath>
</properties>
</project>
我尝试了几种运行 Sonar 的方法:
-
dynamicAnalysis=reuseReports+mvn clean install+mvn sonar:sonar -
dynamicAnalysis=true+mvn clean install sonar:sonar -Dmaven.test.failure.ignore=true -
dynamicAnalysis=true+mvn clean install -DskipTests=true+mvn sonar:sonar(test-run 目标执行期间,单元测试无法运行并出现 NullPointerException)。
有没有办法在 Sonar 仪表板中显示覆盖结果?我是否需要额外的插件(Emma、Clover 等)才能显示标准 Surefire 报告的覆盖范围?是否存在阻止此功能的已知问题?我做错了吗?
更新
我尝试使用 Sonar-Runner 运行 Sonar。有趣的是,仪表板随后完全删除了代码覆盖率小部件。检查运行器的控制台输出表明运行器没有执行FlexSurefireSensor(这是sonar:sonar Maven 目标执行的):
sonar-project.properties 文件包含:
sonar.projectKey=foo:bar
sonar.projectName=Bar
sonar.projectVersion=0.1.0-SNAPSHOT
sonar.language=flex
sources=src/main/flash
tests=src/test/flash
sonar.dynamicAnalysis=reuseReports
sonar.surefire.reportsPath=target/surefire-reports
我使用mvn clean install 运行它,然后是sonar-runner。
【问题讨论】:
标签: maven sonarqube flexunit flexunit4