【发布时间】:2012-03-19 03:32:33
【问题描述】:
我有一些单元测试(虽然它们是 Android 测试,但我使用的是 Robolectric,所以它们在 JVM 上运行)。他们在没有覆盖的情况下快乐地奔跑。
当我尝试覆盖时,我从 emma-maven 收到此错误:
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:emma-maven-plugin:1.0-alpha-3:instrument (default-cli) on project android: Execution default-cli of goal org.codehaus.mojo:emma-maven-plugin:1.0-alpha-3:instrument failed: class [com.larvalabs.svgandroid.ParserHelper] appears to be instrumented already
重要的是class .... appears to be instrumented already。
很难找到合适的文档,但这是我从各种来源拼凑起来的配置:
<plugin>
<!-- This doesn't work, see below for a working configuration -->
<groupId>org.codehaus.mojo</groupId>
<artifactId>emma-maven-plugin</artifactId>
<version>1.0-alpha-3</version>
<inherited>true</inherited>
<executions>
<execution>
<phase>process-classes</phase>
<configuration>
<filters>
<filter>-com.viewpagerindicator.*</filter>
<filter>-com.actionbarsherlock.*</filter>
<filter>-com.larvalabs.svgandroid.*</filter>
</filters>
</configuration>
<goals>
<goal>instrument</goal>
</goals>
</execution>
</executions>
</plugin>
问题是,排除了它抱怨的那些包(我认为问题在于这些是 Android 库项目无意中在某些路径列表上结束了两次),它现在抱怨我自己的包。
一位同事错误地建议上面的
原来
【问题讨论】:
-
您能否详细介绍一下您的项目结构,您是否创建了自己的库项目,是否将 svg android 添加到您的库和主项目依赖项中?
-
事实证明,“已检测”错误是由“执行”元素安排除默认执行之外的检测目标的非默认执行引起的。取出显式阶段将配置默认阶段。我是从几个例子中拼凑出来的,其中一个是试图以一种不适用于我的情况的特定方式添加覆盖范围。
标签: android plugins maven emma