- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
有人能够将 maven2 与 Aspectj 插件和 Cobertura 插件一起使用吗?当我应该得到一些东西时,我一直得到 0% 的覆盖率。 Cobertura 检测在 Aspectj 编织之前运行,我认为这会扰乱 Cobertura 检测。此外,Cobertura 正在就我的方面发出警告,看起来它正试图将它们解析为 java 文件。任何帮助将不胜感激。
C:\project>mvn cobertura:cobertura[INFO] Scanning for projects...[INFO] ------------------------------------------------------------------------[INFO] Building Project[INFO] task-segment: [cobertura:cobertura][INFO] ------------------------------------------------------------------------[INFO] Preparing cobertura:cobertura[INFO] [aspectj:compile {execution: compile}][INFO] [resources:resources][INFO] Using 'UTF-8' encoding to copy filtered resources.[INFO] Copying 1 resource[INFO] [compiler:compile][INFO] Nothing to compile - all classes are up to date[INFO] [cobertura:instrument][INFO] Cobertura 1.9.2 - GNU GPL License (NO WARRANTY) - See COPYRIGHT fileCobertura: Loaded information on 538 classes.Instrumenting 538 files to C:\project\target\generated-classes\coberturaCobertura: Saved information on 538 classes.Instrument time: 3938ms[INFO] Instrumentation was successful.[INFO] [aspectj:test-compile {execution: test-compile}][INFO] [resources:testResources][INFO] Using 'UTF-8' encoding to copy filtered resources.[INFO] Copying 1 resource[INFO] [compiler:testCompile][INFO] Nothing to compile - all classes are up to date[INFO] [surefire:test][INFO] Surefire report directory: C:\project\target\surefire-reports------------------------------------------------------- T E S T S-------------------------------------------------------Running project.AnnounceTypeActionTestTests run: 3, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.594 secResults :Tests run: 3, Failures: 0, Errors: 0, Skipped: 0[INFO] [cobertura:cobertura][INFO] Cobertura 1.9.2 - GNU GPL License (NO WARRANTY) - See COPYRIGHT fileCobertura: Loaded information on 538 classes.Javancss.(InputStream).e: net.sourceforge.cobertura.javancss.ParseException: Encountered "aspect" at line 5, column 8.Was expecting one of: "@" ... "abstract" ... "final" ... "public" ... "synchronized" ... "strictfp" ... "class" ... "static" ... "protected" ... "private" ... "native" ... "transient" ... "volatile" ... "enum" ... "interface" ...[cobertura] WARN [main] net.sourceforge.cobertura.reporting.ComplexityCalculator - JavaNCSS got an error while parsing the java file C:\project\src\main\java\Project\logging\ApplicationLoggingAspect.ajParseException in STDINLast useful checkpoint: "project.logging."Encountered "aspect" at line 5, column 8.Was expecting one of: "@" ... "abstract" ... "final" ... "public" ... "synchronized" ... "strictfp" ... "class" ... "static" ... "protected" ... "private" ... "native" ... "transient" ... "volatile" ... "enum" ... "interface" ...Javancss.(InputStream).e: net.sourceforge.cobertura.javancss.ParseException: Encountered "aspect" at line 4, column 17.Was expecting one of: "@" ... "abstract" ... "final" ... "public" ... "synchronized" ... "strictfp" ... "class" ... "static" ... "protected" ... "private" ... "native" ... "transient" ... "volatile" ... "enum" ... "interface" ...[cobertura] WARN [main] net.sourceforge.cobertura.reporting.ComplexityCalculator - JavaNCSS got an error while parsing the java file C:\project\src\main\java\Project\logging\LoggingAspect.ajParseException in STDINLast useful checkpoint: "project.logging."Encountered "aspect" at line 4, column 17.Was expecting one of: "@" ... "abstract" ... "final" ... "public" ... "synchronized" ... "strictfp" ... "class" ... "static" ... "protected" ... "private" ... "native" ... "transient" ... "volatile" ... "enum" ... "interface" ...Javancss.(InputStream).e: net.sourceforge.cobertura.javancss.ParseException: Encountered "aspect" at line 6, column 17.Was expecting one of: "@" ... "abstract" ... "final" ... "public" ... "synchronized" ... "strictfp" ... "class" ... "static" ... "protected" ... "private" ... "native" ... "transient" ... "volatile" ... "enum" ... "interface" ...[cobertura] WARN [main] net.sourceforge.cobertura.reporting.ComplexityCalculator - JavaNCSS got an error while parsing the java file C:\project\src\main\java\Project\logging\TracingAspect.ajParseException in STDINLast useful checkpoint: "project.logging."Encountered "aspect" at line 6, column 17.Was expecting one of: "@" ... "abstract" ... "final" ... "public" ... "synchronized" ... "strictfp" ... "class" ... "static" ... "protected" ... "private" ... "native" ... "transient" ... "volatile" ... "enum" ... "interface" ...Report time: 5891ms[INFO] Cobertura Report generation was successful.[INFO] Cobertura 1.9.2 - GNU GPL License (NO WARRANTY) - See COPYRIGHT fileCobertura: Loaded information on 538 classes.Javancss.(InputStream).e: net.sourceforge.cobertura.javancss.ParseException: Encountered "aspect" at line 5, column 8.Was expecting one of: "@" ... "abstract" ... "final" ... "public" ... "synchronized" ... "strictfp" ... "class" ... "static" ... "protected" ... "private" ... "native" ... "transient" ... "volatile" ... "enum" ... "interface" ...[cobertura] WARN [main] net.sourceforge.cobertura.reporting.ComplexityCalculator - JavaNCSS got an error while parsing the java file C:\project\src\main\java\Project\logging\ApplicationLoggingAspect.ajParseException in STDINLast useful checkpoint: "project.logging."Encountered "aspect" at line 5, column 8.Was expecting one of: "@" ... "abstract" ... "final" ... "public" ... "synchronized" ... "strictfp" ... "class" ... "static" ... "protected" ... "private" ... "native" ... "transient" ... "volatile" ... "enum" ... "interface" ...Javancss.(InputStream).e: net.sourceforge.cobertura.javancss.ParseException: Encountered "aspect" at line 4, column 17.Was expecting one of: "@" ... "abstract" ... "final" ... "public" ... "synchronized" ... "strictfp" ... "class" ... "static" ... "protected" ... "private" ... "native" ... "transient" ... "volatile" ... "enum" ... "interface" ...[cobertura] WARN [main] net.sourceforge.cobertura.reporting.ComplexityCalculator - JavaNCSS got an error while parsing the java file C:\project\src\main\java\Project\logging\LoggingAspect.ajParseException in STDINLast useful checkpoint: "project.logging."Encountered "aspect" at line 4, column 17.Was expecting one of: "@" ... "abstract" ... "final" ... "public" ... "synchronized" ... "strictfp" ... "class" ... "static" ... "protected" ... "private" ... "native" ... "transient" ... "volatile" ... "enum" ... "interface" ...Javancss.(InputStream).e: net.sourceforge.cobertura.javancss.ParseException: Encountered "aspect" at line 6, column 17.Was expecting one of: "@" ... "abstract" ... "final" ... "public" ... "synchronized" ... "strictfp" ... "class" ... "static" ... "protected" ... "private" ... "native" ... "transient" ... "volatile" ... "enum" ... "interface" ...[cobertura] WARN [main] net.sourceforge.cobertura.reporting.ComplexityCalculator - JavaNCSS got an error while parsing the java file C:\project\src\main\java\Project\logging\TracingAspect.ajParseException in STDINLast useful checkpoint: "project.logging."Encountered "aspect" at line 6, column 17.Was expecting one of: "@" ... "abstract" ... "final" ... "public" ... "synchronized" ... "strictfp" ... "class" ... "static" ... "protected" ... "private" ... "native" ... "transient" ... "volatile" ... "enum" ... "interface" ...Report time: 3125ms[INFO] Cobertura Report generation was successful.[INFO] ------------------------------------------------------------------------[INFO] BUILD SUCCESSFUL[INFO] ------------------------------------------------------------------------[INFO] Total time: 30 seconds[INFO] Finished at: Wed Sep 02 17:15:45 VET 2009[INFO] Final Memory: 26M/254M[INFO] ------------------------------------------------------------------------
最佳答案
我的项目使用 aspectj-maven-plugin 进行编译,并使用 cobertura-maven-plugin 进行代码覆盖。对于编译时编织,这在运行 mvn site
时工作正常,尽管测试被编译/运行两次以允许 Cobertura 编织。
使用以下配置运行 mvn site
会产生以下输出:
[INFO] Preparing surefire-report:report
[INFO] [aspectj:compile {execution: compile_with_aspectj}]
...
[INFO] [compiler:compile]
[INFO] Nothing to compile - all classes are up to date
...
[INFO] [compiler:testCompile {execution: test-compile}]
[INFO] Compiling 8 source files to C:\test\aop-test
[INFO] [aspectj:test-compile {execution: test-compile_with_aspectj}]
...
[INFO] [surefire:test]
...
[INFO] Preparing cobertura:cobertura
[INFO] [aspectj:compile {execution: compile_with_aspectj}]
...
[INFO] [compiler:compile]
[INFO] Nothing to compile - all classes are up to date
[INFO] [cobertura:instrument]
[INFO] Cobertura 1.8 - GNU GPL License (NO WARRANTY) - See COPYRIGHT file
Instrumenting 11 files to C:\test\aop-test\generated-classes\cobertura
Cobertura: Saved information on 11 classes.
Instrument time: 250ms
[INFO] Instrumentation was successful.
[INFO] [compiler:testCompile {execution: test-compile}]
[INFO] Nothing to compile - all classes are up to date
[INFO] [aspectj:test-compile {execution: test-compile_with_aspectj}]
...
[INFO] [surefire:test]
...
Cobertura: Coverage data file C:\test\aop-test\cobertura.ser either
does not exist or is not readable. Creating a new data file.
Cobertura: Saved information on 8 classes.
我的配置包含在下面。
关于您方面的 Cobertura 警告,您可以尝试的一件事是将建议执行主体移动到 java 类型,而不是在方面中定义它。
例如,而不是这样做:
before(Throwable e, Object subject): handlers(e, subject) {
Log logger = getTraceLog(subject.getClass());
//code to trace exception handling
...
}
相反,您可以将实现委托(delegate)给 Java 类型,因此要处理的方面中的代码很少:
before(Throwable e, Object subject): handlers(e, subject) {
Log logger = getTraceLog(subject.getClass());
//get helper type and delegate processing to that type.
getFormatterHelper().traceErrorHandling(logger, thisJoinPoint, e);
}
我对 aspectj 和 cobertura 插件的配置:
<build>
<plugins>
...
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.2</version>
<executions>
<execution>
<id>compile_with_aspectj</id>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<complianceLevel>1.5</complianceLevel>
</configuration>
</execution>
<execution>
<id>test-compile_with_aspectj</id>
<goals>
<goal>test-compile</goal>
</goals>
<configuration>
<complianceLevel>1.5</complianceLevel>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>aspectj</groupId>
<artifactId>aspectjtools</artifactId>
<version>1.6.4</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
...
<reporting>
<plugins>
...
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.1</version>
<configuration>
<formats>
<format>html</format>
<format>xml</format>
</formats>
<outputDirectory>target/site/cobertura</outputDirectory>
</configuration>
</plugin>
<plugins
</reporting>
关于maven-2 - maven cobertura 报告 0% 与 aspectj,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1370385/
从 Cobertura Maven 插件调用 cobertura:instrument 目标可能是什么实际用例? 我知道它只是工具类,但是什么时候它可能比 cobertura:cobertura 或
我正在使用 cobertura maven 插件 2.4。我没有看到任何选项来设置将数据文件 (cobertura.ser) 存储到特定文件夹的位置。 最佳答案 看看http://jira.codeh
我对部署和代码覆盖问题还很陌生,现在我遇到了一个问题,我的应用程序使用 cobertura maven 插件 2.7 和 covertura 版本 2.1.1 和 java 8。我在 cobertur
自从我将我的 sonarqube 服务器更新到 6.1 以来,我在我的 gradle 项目中遇到了这个错误。 我正在使用 Sonar 插件最新版本 (2.2) classpath("org.sonar
我看到在cobertura-maven-plugin中,可以同时使用excludes和ignores配置我的工具。两者有什么区别? 最佳答案 Maven插件不包含有关此配置选项的任何文档(但它们包含在
我正在尝试使用 cobertura 插件生成代码覆盖率报告。 我的 pom.xml 中有这个依赖项 org.codehaus.mojo cobertura-maven-plugi
我为我的grails 3.1.6项目添加了cobertura代码覆盖率,覆盖率报告似乎有点过时,即我有单元测试用例(pos和neg情况)都覆盖了if块,但是报告说没有覆盖率如果-block。 Grad
我正在使用 Maven (2) Cobertura 插件来创建代码覆盖率报告,并且我在方法中使用了以下 stub : try { System.exit(0); } catch (final
我正在使用 Cobertura 进行代码覆盖率分析。如果我在 Jenkins 中运行构建,生成 中的类将包含在覆盖率结果中,但覆盖率为 0%。如果我在工作区 (Eclipse) 中运行代码覆盖率,覆盖
我是 Cobertura 的新手,我正在尝试从编译的 jar 文件中检测类。 解压后,我运行以下命令: D:\cobertura-1.9.4.1\7.6.300.01>D:\cobertura-1.9
我目前正在努力解决Cobertura在某些情况下无法识别给定类的代码覆盖率的问题。尽管该类已经过全面测试(方法覆盖率 100%),但 Cobertura 显示的覆盖率为 0%。 同一包中还有其他类可以
我是第一次使用 cobertura。一切正常,但我想知道的是,我的代码中有几行永远不应该这样调用: try { em.persist(); }catch(Exception) { lo
我创建了一个基本的 Maven 包。 src/main/java 目录包含: public class Blah { public int blah(){ return 1;
我有一个使用 Maven 配置的庞大代码库。我的代码库分为不同的 Maven 模块,因此我有一个主 pom 文件,每个子模块都有自己的 pom 文件。但这些模块仍然互相调用彼此的功能。为每个模块编写
通过 gcovr,我能够为我的 IOS 应用程序生成代码覆盖率报告 (coverage.xml)。我将如何使用 cobertura 插件将 coverage.xml 转换为 cobertura htm
我看到 Cobertura 有一个 可用于在构建时强制覆盖的任务(如果覆盖指标低于某个值,则构建失败)。该网站显示了具有多个可用属性的示例,但并未真正描述它们是什么或它们的作用: branchrate
我正在尝试使用 Gradle Cobertura 插件作为我的 Springboot 应用程序的代码覆盖工具。该应用程序主要是 Java 后端,但确实包含一些常规代码。 我正在使用 Java 1.8.
我从我的 Maven 父项目中删除了一个子项目。 现在,当我在父项目上运行 cobertura:cobertura 时,已经消失的类仍然列在我们 Jenkins CI 的覆盖率报告中。 . 整个 Ma
有人知道 Cobertura 将它的报道图片贴在哪里吗? 我图片的网址是:http://ContinualTests/746/cobertura/graph 当我深入研究运行 tomcat/hudso
经过一些努力我终于得到cobertura我的 Web 应用程序在 tomcat 上正确运行服务器。在我将它提交给 svn 并且 hudson 完成(失败)他的工作之前,一切似乎都很好。如果没有这个构建
我是一名优秀的程序员,十分优秀!