emma没有生成报告,但cobertura呢?

时间:2010-06-10 11:10:41

标签: maven-2 cobertura emma

将比较问题放在这两个之间的基本原因是我能够在我的pom的构建部分中放入以下插件信息后,在站点目录(cobertura)中生成报告。但emma也不会发生这种情况。我检查了codehause mojo中的文档,两者几乎相同。我的配置是:

<plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>emma-maven-plugin</artifactId>
            <version>1.0-alpha-2</version>
            <executions>
                <execution>
                    <phase>process-classes</phase>
                    <goals>
                        <goal>emma</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

但它不会在网站目录中按预期生成报告,但我可以看到每次生成的coverage.em和类检测。我错过了任何配置吗?

2 个答案:

答案 0 :(得分:1)

我无法重现你的问题。我将您的配置代码段复制并粘贴到随机pom.xml并运行process-classes触发器emma:emma后面的任何阶段,并按预期生成覆盖率报告:

$ mvn clean process-classes
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building Test Project
[INFO]    task-segment: [clean, process-classes]
[INFO] ------------------------------------------------------------------------
[INFO] [clean:clean {execution: default-clean}]
[INFO] Deleting directory /home/pascal/tmp/test-project/target
[INFO] [resources:resources {execution: default-resources}]
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] [compiler:compile {execution: default-compile}]
[INFO] Compiling 1 source file to /home/pascal/tmp/test-project/target/classes
[INFO] Preparing emma:emma

...

EMMA: runtime coverage data merged into [/home/pascal/tmp/test-project/coverage.ec] {in 93 ms}
[INFO] [emma:emma {execution: default}]
processing input files ...
2 file(s) read and merged in 3 ms
writing [xml] report to [/home/pascal/tmp/test-project/target/site/emma/coverage.xml] ...
writing [html] report to [/home/pascal/tmp/test-project/target/site/emma/index.html] ...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------

您的项目中是否有单元测试? coverage.em文件是否为空?如果在命令行上运行emma:emma会发生什么?使用-X选项运行mvn会给你提供任何提示吗?你能发布一些有用的痕迹吗?

作为旁注,我不会亲自将emma:emma作为常规版本的一部分运行。我可以从命令行运行emma:emma目标,也可以按照Usage页面中的建议配置插件和报告部分。但这是另一个故事,并没有回答这个问题。

答案 1 :(得分:0)

这真的很奇怪:更正的插件条目是:查看输出目录

<plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>emma-maven-plugin</artifactId>
            <version>1.0-alpha-2</version>
            <inherited>true</inherited>
            <executions>
                <execution>
                    <id>emma</id>
                    <phase>process-classes</phase>
                    <goals>
                        <goal>emma</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <outputDirectory>${project.build.directory}</outputDirectory>
            </configuration>
        </plugin>
emma甚至不接受$ {project.build.directory} / emma。

结论:当您向$ {project.build.directory}添加任何子目录时,emma未生成报告,例如$ {project.build.directory} /艾玛-报告。