jacoco

Sonar + JaCoco not counting Groovy code as covered

假如想象 提交于 2020-01-30 05:49:23
问题 I have a Groovy class with a single static method: class ResponseUtil { static String FormatBigDecimalForUI (BigDecimal value){ (value == null || value <= 0) ? '' : roundHalfEven(value) } } It has a test case or few: @Test void shouldFormatValidValue () { assert '1.8' == ResponseUtil.FormatBigDecimalForUI(new BigDecimal(1.7992311)) assert '0.9' == ResponseUtil.FormatBigDecimalForUI(new BigDecimal(0.872342)) } @Test void shouldFormatMissingValue () { assert '' == ResponseUtil

[持续交付实践] 交付流水线设计:单元测试及覆盖率统计

妖精的绣舞 提交于 2020-01-25 19:10:32
Jacoco简介 Jacoco是一个开源的覆盖率工具。Jacoco可以嵌入到Ant 、Maven中,并提供了EclEmma Eclipse插件,也可以使用JavaAgent技术监控Java程序。很多第三方的工具提供了对Jacoco的集成,如sonar、Jenkins等。 官网地址: http://www.eclemma.org/jacoco/ 支持的集成工具 Jacoco团队提供了如下的一些集成工具的支持: Java API http://www.eclemma.org/jacoco/trunk/doc/api/index.html Command Line http://www.eclemma.org/jacoco/trunk/doc/agent.html Apache Ant http://www.eclemma.org/jacoco/trunk/doc/ant.html Apache Maven http://www.eclemma.org/jacoco/trunk/doc/maven.html Eclipse EclDmma Plugin http://www.eclemma.org/ Jacoco与Eclipse集成 打开 Eclipse 的软件市场,在其中搜索 EclEmma,找到后完成安装,如下图所示: 安装完成后,Eclipse 的工具条里会多出下面这样一个图标:

Merging sonar metrics across a maven multi-module project

送分小仙女□ 提交于 2020-01-25 12:40:09
问题 I've inherited an odd maven multi module project. The standard business classes and unit tests are in a module called 'code' and we've nice simple working sonar metrics for this module. The second module holds various integration style tests which run against a deployed glassfish server, these run as unit test in the integ-test module. pom.xml // root level, code // business code and unit tests :-) moduleA moduleB integ-test // ;-( moduleA moduleB I know the simplest option is to move the

Feed sonarqube jacoco widget with csv/html reports (instead of *.exec)

笑着哭i 提交于 2020-01-24 20:28:33
问题 I got a root maven project, under which there are many independent modules (e.g. module_A, module_B, etc.). One of these module is my integration-tests module, and it uses all the above external modules. In order to have code coverage for all modules used by integration-tests, I use a workaround based on maven-ant (see this blog post). Problem is: The above generates csv/html report, yet sonarqube jacoco widget parses only jacoco*.exec files - which results in 0% code coverage. Question is:

Jacoco and Arquillian in a multi module Maven project

百般思念 提交于 2020-01-24 20:04:39
问题 I am following this article: http://www.softwarepassion.com/it-coverage-with-arquillian-jacoco-extension/ to get test coverage for arquillian integration tests. My project is a multi module though and I don't know where to put the plug in and dependencies. Is it in the top pom, the artifact-making module or in the integration test module? Thank you 回答1: To some extent it depends on the details of your Maven setup, which aren't in your question. Here is some general advice. 1) Where should you

EclEmma, Java8 and Lambda - no coverage on lambda expression

江枫思渺然 提交于 2020-01-21 14:40:23
问题 I have a Java project under Eclipse Luna, with EclEmma 2.3.1.201405111647 (latest), which use Jacoco 0.7.1, which have support for Java 8 as stated in their changelog: "Version 2.3.1 (2014/05/11) Fixed ASM 5.0.1 dependency conflicts with new ASM bundles in Eclipse 4.4 (GitHub #83). Upgrade to JaCoCo 0.7.1 for full Java 8 support. I now have the following toString: @Override public String toString() { // [BLOCK0] if (0 == value) { return "0B"; } // [BLOCK1] final MutableLong val = new

Maven工程配置代码覆盖工具Jacoco

浪尽此生 提交于 2020-01-21 01:17:15
Jacoco是一个开源的Java代码覆盖率工具,Jacoco可以嵌入到Ant 、Maven中,并提供了EclEmma Eclipse插件,也可以使用JavaAgent技术监控Java程序。很多第三方的工具提供了对Jacoco的集成,如sonar、Jenkins等。 Maven工程 创建Maven工程 打开Eclipse,File->New->Project->Maven Project,新建一个Maven工程~ 点击“Next”按钮,然后填写groupId和artifactId信息后点击"Finish"按钮即可~ groupId --> com.xxx.tutorial artifactId --> jacoco-demo 配置Jacoco 添加maven-complier-plugin <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.6.1</version> <configuration> <skipMain>true</skipMain> <skip>true</skip> <source>1.7</source> <target>1.7</target> </configuration> <

Missing branches when using assertTrue instead of assertNull

廉价感情. 提交于 2020-01-21 01:11:13
问题 In Java/Junit, I need to test for null with some object. There are a variety of ways I can test a condition but I have been using assertTrue for most of my tests. When I check for nulls in an assertTrue, EclEmma states that it is only testing one branch. When I resolve the statement into a variable manually (like setting the result to a boolean and passing it into assertTrue) the code coverage is deemed complete on the assert but not on the variable initializing line. Why is this happening?

Maven集成Docker+ Spock + jacoco + sonar

只谈情不闲聊 提交于 2020-01-16 18:54:25
1.执行maven 命令: clean package sonar:sonar 即可上传镜像并将测试报告上传到sonar 2. 如果没有配置环境变量: SONAR_URL ,则执行命令: clean package sonar:sonar -D sonar.host.url=http://10.102.129.22:9000 1. pom.xml 文件 <?xml version="1.0" encoding="UTF-8"?> < 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 https://maven.apache.org/xsd/maven-4.0.0.xsd " > < modelVersion > 4.0.0 </ modelVersion > < parent > < groupId > org.springframework.boot </ groupId > < artifactId > spring-boot-starter-parent </ artifactId > <

JaCoCo (Offline Instrumentation) in <goal>instrument</goal> analyzes the entire pom.xml. But I need only the tests part

你。 提交于 2020-01-15 03:54:12
问题 Basically I need jacoco only instrument the tests part, but is instrumententing the entire pom.xml, and the report came with everything (Data from “oracle.jdbc.driver”, “com.mysql.jdbc”… etc.) I've been trying for a couple of days with almost everything. But I have not succeeded so far Notice here how jacoco:instrument instrument the entire pom.xml [INFO] --- jacoco-maven-plugin:0.8.4:instrument (default-instrument) @ myApp --- ... [DEBUG] (f) project = MavenProject: com.firstPackage.tdz