How to generate Aggregate report in Jmeter after maven execution? - maven

I am running my JMeter scripts from Jenkins via jmeter-maven-plugin. The jtl file gets generated successfully. But not able to automatically generate the Aggregate report from the jtl file. Looks like maven does not create the JMeterPluginsCMD Command Line Tool even after adding the below dependency in pom.xml
<jmeterExtension>kg.apc:jmeter-plugins-cmd:2.2</jmeterExtension>
Please help on how to configure JMeter to create the Aggregate report, so that I can archive the report in Jenkins and make it available for download.

First of all your syntax is not correct, it should be something like:
<jmeterExtensions>
<artifact>kg.apc:jmeter-plugins-cmd:2.2<</artifact>
</jmeterExtensions>
Second, JMeter Maven Plugin provides possibility to generate HTML Reporting Dashboard given you have the following line in your POM file:
<generateReports>true</generateReports>
and the dashboard has its own version of the Aggregate Report table (plus APDEX plus interactive zoomable charts)
More information: How to Use the JMeter Maven Plugin

Related

Maven surefire plugin output test summary xml?

I am in a project that uses the Surefire and Failsafe maven plugins to run unit and integration tests respectively. The output of failsafe produces a summary of the test run in target/failsafe/failsafe-summary.xml. I would like to get a similar .xml summary report from surefire, however I can only seem to get an xml file per test suite there.
Is it possible to configure surefire to do this?
Is it possible to configure surefire to do this?
(create 1 report file/run instead of 1/test suite)
No, not without customizing surefire/surefire-report plugin.
Since the only (up-to-date) "output related" configuration options (of surefire-plugin:test) are:
encoding
redirectTestOutputToFile
reportFormat (default - "brief", alternatively - "plain" (*.txt files))
reportNameSuffix
reportsDirectory
And surefire-report plugin's only purpose is maven report (html!) generation.
For this special need, I'd recommend a custom script or (maven) plugin (basing on one of the above - they are open source). You can also try "to tackle the problem from source" by combining all of your test classes/suits into one!? :)

Sonarqube: Import Jacoco xml report for multimodule

I have a multimodule Maven project where the coverage reports are located in another module than the covered Java classes. An import of a not empty xml coverage report (with coverage information) into Sonarqube is successful but shows a coverage of 0.
Steps to reproduce:
Checkout following github project and build it with mvn clean verify. After that there exist an aggregated xml report located in coverage/target/site/jacoco-aggregate-all/jacoco.xml. You can see coverage data in there and also in the corresponding html-Report.
Start sonarqube (current version 8.4.1) with following command and wait a little bit.
docker run -d -p 9000:9000 sonarqube
edit: Plugin "JaCoco xml report importer" is already installed in this image.
Publish coverage data with following (verbose) command. Importing of report was successful (see log).
mvn sonar:sonar -X -Dsonar.projectKey=example -Dsonar.host.url=http://localhost:9000 -Dsonar.login=admin -Dsonar.password=admin -Dsonar.coverage.jacoco.xmlReportPaths=target/site/jacoco-aggregate-all/jacoco.xml
## Log output contains
...
10:54:28.519 Reading report '<project-path>\maven-multimodule-coverage\coverage\target\site\jacoco-aggregate-all\jacoco.xml'
...
Browse to http://localhost:9000/dashboard?id=example. You see coverage of 0.
What am I doing wrong?
It turned out that it works if I use an absolute path for the xml report file. So I added
<sonar.coverage.jacoco.xmlReportPaths>${project.basedir}/../coverage/target/site/jacoco-aggregate-all/jacoco.xml</sonar.coverage.jacoco.xmlReportPaths>
to the top maven pom so each module points to the same report file. For a deeper nesting of module directories you have to introduce a property main.basedir or something.
The main understanding is that you do not provide sonar a coverage report which get mapped to the module classes, but you provide module classes which get mapped to a coverage report.
Please install JaCoco xml report importer plugin on sonarqube instance (you will find it under marketplace just search for jacoco there). This plugin will pick up your code coverage and import it to sonarqube. so after installing plugin please use the same command to see result on sonarqube which is
mvn sonar:sonar -X -Dsonar.projectKey=example -Dsonar.host.url=http://localhost:9000 -Dsonar.login=admin -Dsonar.password=admin -Dsonar.coverage.jacoco.xmlReportPaths=target/site/jacoco-aggregate-all/jacoco.xml

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

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:
EDIT
here's an example project for the problem above.
You don't need to use that workaround. You can provide Sonar with integration tests coverage file with following property (you shall use it while executing sonar:sonar goal):
-Dsonar.jacoco.itReportPath=<coverage_file>
Here is detailed documentation:
http://docs.codehaus.org/display/SONAR/Code+Coverage+by+Integration+Tests+for+Java+Project
To sum up:
Compile all your modules.
Execute integration tests with jacoco enabled.
Execute Maven Sonar build adding mentioned property in command line.
I have prepared example project generating both unit and integration coverage results, you can check it here:
https://github.com/octosan/unit-and-integration-jacoco-coverage-with-sonar
You have to:
download newest Sonarqube version and start it
execute command:
mvn clean install sonar:sonar -Dsonar.jacoco.itReportPath=<absolute_path>/itest/target/jacoco-it.exec
add integration coverage widged in project dashboard in Sonar

SONAR importing cobertura.ser coverage reports to sonar server using mvn sonar:sonar?

I have a cobertura.ser file, that got generated while integration-test and system test. Now I want to import my coverage this to sonar server.
How can I achieve this, so while executing mvn sonar:sonar the coverage should consider external coberture.ser file?
Can I do this using sonar, where i can see overall coverage obtain during all test run?
You need to set the following paramater to tell Sonar to use a pre-generated report:
sonar.dynamicAnalysis=reuseReports
Secondly Sonar doesn't read the "cobertura.ser" file. It can be configured as follows to read the generated XML report (See cobertura docs):
sonar.cobertura.reportPath=target/reports/coverage.xml
Finally, my reference for all this stuff comes from the from the Sonar wiki:
http://docs.codehaus.org/display/SONAR/Advanced+Parameters
http://docs.codehaus.org/display/SONAR/Code+Coverage+by+Unit+Tests
http://docs.codehaus.org/display/SONAR/Code+Coverage+by+Integration+Tests
The Sonarsource tutorials are increasingly pushing JaCoCo. This appears to be an emerging standard (replacing the older defunct Emma project)

Jenkins JDepend Plugin reports JAR classes

I am using 1.467 and Jenkins JDepend plugin 1.2.3.
When I build, it generates the JDepend report.
No problem.
THe problem is that I get reports on classes like:
org.apache.commons.fileupload
org.hibernate.ejb
Packages report on classes that I didn't write.
How I configure this so that it JDepend only run on classes that I write?
com.mycompany.myproject
for example.
Thanks.
JDepend Maven Plugin looks quite old and seems to be in beta. It does not support a way to exclude packages/classes. I assume jenkins JDepend Plugin uses the information from this to generate the report.
JDepend itself provides options to include/exclude classes/packages from analysis. JDepend ant task provides support for this as well.
One possibility would be to use jdepend ant task using maven antrun plugin (or directly invoke jdepend using maven exec plugin) to do the analysis and specify the report file to jenkins plugin for reporting.
i got it to work by setting the goal to "jdepend:generate" and setting the Pre-generated JDepend file to "target/jdepend-report.xml"

Resources