jacoco

Dump execution data at run time

跟風遠走 提交于 2019-12-10 20:35:44
问题 I'm using JaCoCo to generate code coverage report and I have a number of scenarios to generate separate reports for. The problem is that the program is extremely huge and takes around 2 minuted to start and load all the class files. I want to fetch the execution data on run time as soon as one of those scenarios is completed and then start with the next scenario, instead of restarting the server for each scenario. Is there a way to do so? 回答1: All below is taken from official JaCoCo

jacoco: For report generation the same class files must be used as at runtime

拈花ヽ惹草 提交于 2019-12-10 13:56:34
问题 I have been working on the android project and use roboletric and powermock to do the unitTest. When I run gradle jacocoTestReport , it will show [ant:jacocoReport] Classes in bundle 'app' do no match with execution data. For report generation the same class files must be used as at runtime. [ant:jacocoReport] Execution data for class com/my/app/MyClass does not match. Where I use powermock to mock the static method in Myclass.java @RunWith(RobolectricGradleTestRunner.class) @Config(constants

Jacoco coverage for switch statement

可紊 提交于 2019-12-10 13:16:55
问题 I am working to get 100% code coverage for a library I am working on and I seem to have some issues with a switch statement and the coverage which I simply don't understand. I am currently using Jacoco 0.7.2 because every newer version seems to break with Robolectrics. I test a simple switch statement: public enum Type { NONE, LEGACY, AKS } private static Class<?> getCipherClass(Type type) { switch (type) { case LEGACY: return CipherWrapperLegacy.class; case AKS: return CipherWrapperAks.class

Jacoco - Zero Percent Coverage

筅森魡賤 提交于 2019-12-10 12:55:17
问题 I am trying to integrate jacoco to our ant build and evaluate it with a simple test project. The compilation and the other output looks promising, but when I look at the coverage it is always zero. package alg; public class SpecialAlgorithm { public SpecialAlgorithm() {} public int uncoveredMethod(int i) { return i * i; } public int sum(int i, int j) { return i + j; } } Testcase: package alg; import static org.junit.Assert.assertEquals; import org.junit.Test; import alg.SpecialAlgorithm;

JaCoCo ignoring Lombok code, is this expected?

£可爱£侵袭症+ 提交于 2019-12-10 11:56:29
问题 I am using Lombok 1.18.2 and JaCoCo 0.8.3, which theoretically recognize/ignore lombok annotations. I did a test, added the lombok.addLombokGeneratedAnnotation = true param in my lombok.config and then I see the generated annotation on my target classes decompiled code. But I am surprised to open jacoco.exec file and see that things like @Getter increase the "Total Probes" values, but keep untouched the "Executed Probes" one. Is this expected? If so, how can SonarQube make smart use of it, if

Is there a plugin which will load a jacoco-it.exec data file (coverage data) into SonarQube without java source or classes present?

馋奶兔 提交于 2019-12-10 11:51:37
问题 In reading many posts there are many cases where users have used the jacoco agent to generate coverage data (i.e. created an exec data file either jacoco.exec or jacoco-it.exec). However, there are a number of questions about getting the data into SonarQube. In many of these use cases by the time the exec data file is created it is disassociated from the build time project structure. Can you load a jacoco exec data file into SonarQube without having related class or source files? If yes,

jacoco coverage per test setup

自古美人都是妖i 提交于 2019-12-09 21:37:32
问题 I'm using jacoco in order to gather code metrics and import them to sonarQube but i was missing details about coverage per test. So after searching about it i came to this tutorial but failed to make it work on my project. here is my pom.xml <properties> <sonarVersion>2.4</sonarVersion> <spring-framework.version>4.0.0.RELEASE</spring-framework.version> <spring-framework.security.version>3.2.5.RELEASE</spring-framework.security.version> <jackson.version>1.9.13</jackson.version> <jacoco.version

jacocoTestReport task not being generated

房东的猫 提交于 2019-12-09 16:16:01
问题 Android Studio 3.1 Canary 8 Build #AI-173.4529993, built on January 6, 2018 JRE: 1.8.0_152-release-1024-b01 amd64 JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o Linux 4.14.14-300.fc27.x86_64 I am trying to use the jacoco to generate code coverage. However, when I run the command ./gradlew tasks I don't see any tasks called jacocoTestReport . I get the below error when I try and run the tasks ./gradlew jacocoTestReport : Task 'jacocoTestReport' not found in root project 'EnumSample' This is

Cobertura : how to cover spring-data @Repository interfaces

半腔热情 提交于 2019-12-09 16:12:03
问题 Regarding following information : https://stackoverflow.com/a/14601831/704246 Cobertura does not instrument interfaces I'd like to know how to add spring-data interfaces to coverage results, since @Repository implementation classes are only declared and instantiated by Spring at runtime. Consider following interface : // src/main/java/my/package/MyObjectRepository.java @Repository public interface MyObjectRepository { MyObject findMyObjectByCodeAndName(String code, String name); } and

Sonar Maven Plugin: How do I exclude test source directories?

送分小仙女□ 提交于 2019-12-09 14:33:02
问题 I have a Maven project with Java sources and Scala test sources. I generate code coverage using Jacoco during the verify stage. When I try to run the sonar goal either during the verify phase by adding an execution, or by running mvn verify sonar:sonar , I end up with the test directory being added twice by Sonar: [INFO] [11:15:34.756] Test directories: [INFO] [11:15:34.756] /Users/xxx/Documents/workspace/misc/xxx/src/test/scala [INFO] [11:15:34.756] /Users/xxx/Documents/workspace/misc/xxx