For my project I get a good coverage report by jacoco for the models, but no coverage is shown to the controllers. Is there any configuration option that needs to be applied to jacoco to cover the static methods in the play framework controllers?
This is the command line to launch the automated tests in play with jacoco:
$ play-1.2.7/play auto-test PWO -javaagent:../jacoco/lib/jacocoagent.jar
There are some problems with Jacoco, if you combine it with Mockito or Powermock. Maybe it is your case as well:
Mockito - https://code.google.com/p/mockito/issues/detail?id=385&q=jacoco
Powermock - more than one issues. See https://code.google.com/p/powermock/issues/list?can=2&q=jacoco&colspec=ID+Type+Status+Priority+Milestone+Owner+Summary&cells=tiles
As far as I think, Jacoco has no problem with static methods or static initializers.
Related
In my Java app, in order to generate coverage reports for my Unit Tests, I have tried several approaches to setup Jacoco as in Run with coverage or this page. However, I cannot generate coverage reports as expected and I think I need some steps describing the setup of Jacoco on IntelliJ. So, does anybody else have experience for setup and run it via command line as shown below:
mvn --global-settings ../settings.xml
-Dtest="/com/mycompany/core/service/impl/unit/ProductServiceImplTest.java" test
Any help would be appreciated.
hi all i have build unit testing for controller, repository and Service but why in my sonarqube code coverage always give me code coverage only 0 percent. my question is how to make my percentage up ?
here what i was code in my testing
Sonarqube uses existing code coverage reports from JaCoCo (in the case of Java). Usually, you would set up the JaCoCo Maven plugin (or Gradle) to gather coverage info on test run and Sonarqube then loads this report.
See also the Sonarqube docs for info on setup. But if you are using Maven/Gradle, I believe Sonarqube is able to automatically pick up the correct file unless you have some special configuration.
I am currently building automated tests which will be generated dynamically in their own class (e.g. TestClass1234567890.class). From those tests (which I will run with the JUnit Platform Launcher) I want to generate a JaCoCo rapport.
Whenever I look up examples for the JaCoCo API, they only show it with a class that implements Runnable, which does not make sense since you'd want to run it on a test class.
Can anyone point me in the correct direction on how to combine the JaCoCo API with the JUnit Platform Launcher? Any resource/example would be appreciated.
You use jacoco report maven plugin:
org.jacoco:jacoco-maven-plugin:0.8.7-SNAPSHOT:report
together with its optional parameters you could define how do you like it
check here
I'm figuring out how JUnit works. I can't understand how it runs itself, I understand that the surefire plugin interacts with JUnit, but I don't understand how JUnit itself runs. I'm trying to understand the debug output, and came across the getRunner method, but I can't get down to it, I can't understand what kind of package com.intellij.rt.junit is. Can you help me.
com.intellij.rt.junit is a package of IntelliJ for its built-in runner for JUnit tests, just like Surefire is the runner when tests are run from Maven.
JUnit itself also contains a basic commandline runner. For JUnit 5, see Console Launcher, for JUnit 4, see Test runners. These are probably - but I didn't check it - easier to understand than the internals of the runners of Surefire or IntelliJ.
How to turn off code coverage in SonarQube 4? I have JMockit usage in unit tests and JaCoCo code coverage plugin in Sonar. They conflict because they use different javaagents to edit bytecode of classes (as I know). I want to switch off code coverage in Sonar. I can exclude my project in settings of Jacoco, but it doesn't help.
I recommend following the paragraph "Ignore Code Coverage" in this documentation:
http://docs.sonarqube.org/display/SONAR/Narrowing+the+Focus