I'm trying to get end-to-end test coverage with Jacoco which is based on API hit, not by running unit test. I followed this tutorial:
https://dzone.com/articles/code-coverage-report-generator-for-java-projects-a
However I got this error:
Caused by: java.lang.LinkageError: loader 'bootstrap' attempted duplicate class definition for java.lang.$JaCoCo. (java.lang.$JaCoCo is in module java.base of loader 'bootstrap')
I don't know what cause the error:
The project uses gradle and I also apply jacoco plugin for unit test (I need coverage for both unit test and end-to-end test).
But I'm not sure if that cause the LinkageError because if I remove all jacoco related things from gradle, the same error still appears.
How to properly setup jacoco coverage for end-to-end testing with gradle? If not possible, is there any alternative?
Related
We have a project written by spring boot with maven. We want to do Unit test and code coverage rate check. To keep project code clean, we want separate the unit test code off.
We want to be two differenrt source project. One was project code, other was unit test code. Use jenkins to run unit test and use Jacoco to see code coverage rate.
Here is how we do it but failed:
generate origin jar from maven which not package by spring framework.
Create new project used Spring boot + TestNg. (name Test_Project)
import the origin jar from project into Test_Project.
Run it with failed:
Field abc in 'com.example.ngtest.TestNGWithSpringApplication' required a bean of type 'com.example.web.controllers.ABController'
that could not be found
Can you help me for any information ?
I am attempting to upgrade our application to Java 8 and am having some issues with maven and surefire. When I run all of my unit tests, a handful of them fail when using EasyMock.createMock with the following error: java.lang.NoClassDefFoundError: Could not initialize class com.sun.proxy.$Proxy33. Not all instances of EasyMock.createMock fail, and I can't find anything special about the classes we're mocking where it fails. Also, if I run the unit test inside of IntelliJ it works perfectly fine. It's only when running it via maven directly that it fails. I haven't been able to find anything that is causing this, but I'm assuming it has to be some sort of classpath issue. Any help would be greatly appreciated.
That is a strange error. The Proxy33 means you are mocking an interface. And that something failed at class loading.
Check if you have static initializers in your code. You can also add remote debug to maven and break on the exception.
We've been adding an increasing number of Groovy (Spock) unit tests to our existing suite of Java (JUnit) tests.
We've configured things correctly to get Spock code coverage listed in Sonar, but the "Unit Test Success" listings - Tests, Failures, Errors, Skipped tests - only shows for the Java tests.
What configuration do we need to add for the Spock tests to report correctly?
Thank you
Those results in Java are fed by the Unit Test execution report, which is separate from the coverage report. The docs tell you how to feed that data into an analysis.
I am using Karma Test Runner on my JavaScript project to generate a Unit Test Report (target/surefire-report/TESTS-karma.xml) but I am unable to make SonarQube import this by setting 'sonar.dynamicAnalysis' to 'reuseReports'.
I configured my Maven POM as follows:
<sonar.language>js</sonar.language>
<sonar.inclusions>app/**,astCommon/**</sonar.inclusions>
<sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
<sonar.javascript.jstest.reportsPath>target/surefire-reports</sonar.javascript.jstest.reportsPath>
<sonar.javascript.jstestdriver.reportsPath>target/surefire-reports</sonar.javascript.jstestdriver.reportsPath>
<sonar.junit.reportsPath>target/surefire-reports</sonar.junit.reportsPath>
<sonar.surefire.reportsPath>target/surefire-reports</sonar.surefire.reportsPath>
(I guess "sonar.javascript.jstest.reportsPath" is the right property but just to be sure I did include some other properties as well)
What also surpises me is that I do not get a warning when I enter an incorrect path in 'sonar.javascript.jstest.reportsPath'. I kind of expected 'Reports path not found'. This makes me suspect that SonarQube somehow is not aware that it should reuse the existing report.
Any hint is appreciated.
Thanks and best,
Ronald
I am calling Sonar from my Jenkins job
I noticed that the coverage of the classes in my domain module all show as having 0% test coverage even though the domains are being used in the other modules which have high test coverage. I am using cobertura within Sonar for measuring the coverage
Can anyone offer any insights into how to get Sonar/Cobertura to recognise the test coverage for the classes in the domain module
Thanks
Damien
By default, Sonar computes unit test coverage. So if your domain classes are not unit-tested in the module where they are defined, this is normal that you don't get unit test coverage for those.
You can have a look at how to add integration test coverage in Sonar: see https://github.com/SonarSource/sonar-examples/tree/master/projects/code-coverage/combined%20ut-it/combined-ut-it-multimodule-maven-jacoco
But that'd be best to have "real" unit tests for your domain classes to test their logic in an isolated context.
Edit
Link to sonar-exmaple-multiple-modules