I am running my selenium project module which isn't part of the main project,
I run the selenium tests with Jacoco maven plugin and the surefire plugin,
The Jacoco gives a code coverage (exec file) only of the selenium project and not for the whole project...
How do i need to configure my Jacoco and Surefire in order to get an external/whole project coverage??
It is not true that you can not measure code coverage of your selenium tests.
Take a look a t JaCoCo as a tool: https://www.eclemma.org/jacoco/
It can measure the code coverage of: unit, integration, GUI tests and to combine it in one aggregated report.
You need to configure a jacoco java agent (tcpserver) in the running project to be tested & a jacococlient (jacococli.jar) to listen to the results.
Example:
java -javaagent:path/to/your/jacocoagent.jar=address=*,port=36320,destfile=jacoco-it.exec,output=tcpserver -jar target/yourApplication.jar
Run end-to-end integration tests.
Dump the results:
java -jar path/to/your/jacococli.jar dump --address localhost --port 36320 --destfile target/jacoco-it.exec
sleep 5
java -jar path/to/your/jacococli.jar report target/jacoco-it.exec --classfiles target/classes --sourcefiles src/main/java/ --html target/jacoco-report
I'm not sure if I do not understand your question correctly… But if I understand it correctly, you want to see the code coverage for Selenium Tests on the productive code?
That is simply impossible! Selenium helps you test the web application. Your code is not being tested with Selenium, but just the web pages resulting from the process of your application.
Related
I would like to run Junit tests via maven command like having the test result
with the same graphical message that I can see using Eclipse IDE.
For example, if I run Junit test via Eclipse I can see this tree image:
But, if I run the same tests via maven command line, I can see only the grand total result without details.
For example:
There is a way to run maven command line tests and receive the test result like Eclipse IDE?
I use surefire plugin on my project.
Thanks in advance.
I use sonarqube for analyzing a project with mixed Java / Groovy tests. The Java tests are run via TestNG, whereas the Groovy tests are run via JUnit. When running the Gradle "sonarqube" task, I get the following in build log (with --debug option):
14:38:53.842 [DEBUG] [org.sonarqube.gradle.SonarQubeTask] Class not found in resource cache : a.b.c.SomeSpec
14:38:53.842 [WARN] [org.sonarqube.gradle.SonarQubeTask] Resource not found: a.b.c.SomeSpec
This is only logged for Groovy tests.
I use two separate tasks to run JUnit / TestNG tests, and a JacocoMerge task from the Gradle Jacoco plugin to merge the binary reports from those tests. As a result, Sonarqube displays the coverage percentage correctly, however, when displaying the list of unit tests, all JUnit (hence, Groovy in my case) tests are missing.
I read No Unit Test Success data for tests written in Groovy and tried using the latest version of the plugin, however, the issue still persists. Is there any way to get both coverage AND unit test information to be displayed properly in Sonarqube using the SonarQube Gradle plugin?
I used SonarQube version 5.6.3., sonarQube Groovy plugin version 1.4 and sonarqube-gradle-plugin version 2.2
I am using Maven to run EUnit tests on my Erlang project and then making a static code analysis. I do not know how to configure the coverage report path so that SonarQube could also show my code coverage results.
In your Maven goals, append the following
-Dsonar.erlang.eunit.reportsfolder=PATH-TO-YOUR-REPORT-FILES
For me following setting worked
-Dsonar.erlang.eunit.reportsfolder=_build/test/cover
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
I have:
a pom.xml which includes junit 4.4, log4j 1.2, and maven-surefire-plugin
Some Scala tests with #RunWith(classOf[JUnitRunner]) and FunSpec
To run it, I do maven clean test etc.
I can generate Surefire HTML reports with a surefire-report Maven switch, but they're not very detailed and I don't think they conform to standard JUnit reports?
Any hints on how I can get a JUnit report output with a nice format (e.g. HTML + CSS)?
Thanks.
The surefire-report:report and surefire-report:report-only goals will generate HTML report for Maven test execution. As part of Maven site generation it could be further styled using one of the skins
You may try Allure Reports which can generate a report website .
A sample project here