Using : JaCoCo 0.5.3, Maven2, Sonar 2.14, sonar-maven-plugin 1.8, SùartGWT 3.0
Currently trying to : Get code coverage on Sonar of my Selenium unit tests.
Problem : Code coverage doesn't move from 0% although the sensor is launched properly, analyse the jacoco.exec which is correctly generated.
Ressources : https://gist.github.com/2888912 The pom.xml
It's been about 2 weeks I'm trying to get code coverage. I upgraded the Sonar from 2.10 to 2.14, changed every single sonar property, tried the plugin jacoco (for maven) and I still DON'T get any results. So if someone had the same problems and found the solution, could you please tell me how you amde it work ?
I'm quite sure my tests must generate at least 0.5% of code coverage. My Selenium tests are actually executed in SeleniumTestLoginEntry.java, does it have any incidence ? Must I call it TestLoginEntry.java ? (The tested class is LoginEntry.java)
I'm using surefire to start the javaagent of JaCoCo (see the tag) and it actually GENERATES the jacoco.exec.
Please give me some help, I'm totally lost I have only one week left to make it work... :(
Thanks in advance.
I'm in a slightly different setup than you are, using Ant and Sonar 3.01, but... there was one property that did the trick for me, that seemed to be almost entirely undocumented when I looked. I notice the wiki pages have had updates in the last couple of days, which may have changed the doc situation.
<property name="sonar.core.codeCoveragePlugin" value="jacoco" />
<property name="sonar.jacoco.reportPath" value="${test.log.dir}/jacoco.exec"/>
Setting sonar.jacoco.reportPath explicitly to the file, not a directory, was what finally worked for me.
Related
I have set up SonarQube, Maven and Cobertura to upload unit test coverage at every build run. I want to use the differential views to get coverage for the delta (new code only).
The coverage itself is successfully uploaded, and I can see the delta in lines of code. However, I can't get the "Coverage on new Code" to work.
I tried different values for the leak period, including previous_analysis and previous_version (changing the version from 1.0 to 1.1 in the new analysis). I also used -Dsonar.projectDate to simulate a past date of analysis but still no luck.
Any thoughts?
The key requirement to obtain new_code -related information/metrics is to leverage SonarQube SCM integration. And to benefit from that you have to install a compatible SCM Plugin applicable to your project (e.g. Git Plugin, SVN Plugin etc.).
"Coverage on New Code" is only displayed if you are using/activating SCM support (SVN, Git, ...).
sonar.scm.disabled=false
Adding this sonar.java.binaries=classes directory, most likely target/classes
helped me in fixing this issue. No JaCoCo analysis of project coverage can be done since there is no class files
Is it possible to use jacoco in sonar without writing junit as I have added jacoco plugin in sonarqube but when I ran the sonar scanner then it is showing 0% code coverage. Please advise me on this as I am new to this work.
JaCoCo is a coverage tool that will record, during an execution of the Junit test where the execution went through your code.
So short answer is : no. This makes absolutely no sense.
(this is a bit simplified but given the question I am keeping things short here).
you can use jacoco java agent, which has nothing to do with junit, and just run your code, then report the code coverage. See this doc for more details
https://www.jacoco.org/jacoco/trunk/doc/agent.html
I'm pretty new to Sonar, I'm using surefire for the metrics, and I've been just wondering how can I modify the Sonar overall coverage to increase or reduce this value to make it fail my Jenkins job.
Can someone point me in the right direction? I cannot find any documentation so far.
I'm not up to date what with the jenkins integration of sonar. Earlies you could install the build breaker plugin. Depending on your Sonarqube version this will no longer work.
Usually the thresholds for your project are not configured as parameters in the project but within sonarqube. Prior to 4.3 this was done through alerts. Nowadays it's called Quality Gates.
Actually a quite good question. I could not find anything for the maven plugin itself to set up some thresholds.
It seems to be an ongoing discussion.
Hi I configured sonarqube and triggered maven run for unit test cases.
I am able to get unit test cases success,failure details but rest all details under Time machine page are blank.
Can any one please help me on this
I think u have to independently produce coverage xml and absorb it in sonar. Major changes happened in sonar 4.3 wherein sonar folks removed the support for tools which helps in producing coverage. Please check it out!. Moreover if you find this post useful please like it.
I have an Xcode 4.5 project for iOS 6.0 and I am trying to set up test coverage for Jenkins with Cobertura.
I have set up a test target and have configured both the main target and the test target correctly (Instrument Program Flow and Generate Test Coverage Files both on YES).
When the coverage report is generated (.gcda file), I translate it into XML using the gcovr tool (version 2.4).
When I run the test on Jenkins, everything works fine and I can see the report through the Cobertura plugin. The only problem is that in the Cobertura report all the values for "Conditionals" are "N/A", while I see that there are conditionals (if-constructions) in the covered files.
My guess is that something happens in the translation to XML resulting in a faulty conversion of branches/conditionals, but I cannot find what it is.
The strange thing is that for some if constructions it does recognise the conditional. For example if I use the "STAssertEquals()" macro from the "SenTestingKit" library, the if constructions there are recognised.
I hope someone can help me with a fix for this problem or at least knows the cause. Please do not hesitate to ask me if you need more information.
Nicolas