Gradle Plugin to generate cucumber report not compiling - java

I am writing Cucumber Automated Test Cases in java, using REST Assured.
All the tests run as JUnit tests, & as Gradle tests, & they all pass successfully.
The next step I need to take is to generate a Cucumber Report based on these test results.
I've been told that I need to find a gradle plugin for cucumber.
So far, I've tried putting the following code (from here: https://plugins.gradle.org/plugin/com.github.spacialcircumstances.gradle-cucumber-reporting) into my build.gradle file:
plugins {
id "com.github.spacialcircumstances.gradle-cucumber-reporting" version "0.0.12"
}
But, when I try to refresh the gradle, I get this error:
Sychrnoize Gradle projects with workspace failed due to an error in the referenced Gradle build.
Is this the correct plugin to generate this cucumber report, and if so, why is it not being accepted by the gradle?

Related

Different jacoco coverage results in a github action environment

is there any reason for a jacoco coverage report to produce different results when running it in a CI environment?
I have the following situation after migrating to Java 17. when I run ./gradlew clean build the report is generated and the jacocoTestCoverageVerification doesnt fail.
But when the same command is executed in a github runner I have a very different result, the coverage report is also created with different coverage values and some classes just fail the coverage verification.
Unfortunately, I cannot provide code snippets but I already tried this:
Run the github runner on my machine, with the same jdk and it produces a different result if I just run the build in the command line :(
add jvmargs noverify for tests tasks
run the github action in a container instead of a self-hosted, same result
other devs have also built the project on different machines without error
run the same build command of the ci
So it seems that something in a github action env produces this behavior.
versions:
jacoco plugin: 0.8.7
gradle 7.3
java 17
The problem here was lombok config files. It turns out that the new version of lombok plugin compatible with java 17 and Gradle 7.3 does not generate the lombok.config files anymore.
In the previous version, these files were generated by io.freefair.lombok plugin, and we had them in .gitignore. Because of that, a local build worked just fine, since the files were still there.
I realized this by looking at the generated reports and I noticed that lombok classes were being analyzed only by the CI.
In other cases, a similar problem could be related to this:
https://www.eclemma.org/jacoco/trunk/doc/classids.html

SonarQube 8.2 Analysis shows 0 code coverage

SonarQube: 8.2.0.32929
sonar-scanner: 3.0.3.778
jacoco: 0.8.4
jdk: 1.8
mvn: 3.6.3
What are you trying to achieve
I am trying to achieve code coverage by using sonar-scanner but I am getting code coverage 0 in sonarqube dashboard.
What have you tried so far to achieve this
I configured the multi-module java project using https://github.com/SonarSource/sonar-scanning-examples/tree/master/sonarqube-scanner-maven/maven-multimodule
and created sonar-project.properties file in base directory with below configuration
sonar.projectKey=org.sonarqube.sonarscanner-maven-aggregate
sonar.projectName=Sonar Scanner Maven Aggregate
sonar.projectVersion=1.0
sonar.language=java
sonar.java.binaries=.
If I use mvn sonar:sonar it works. but with sonar-scanner it is not working.
It works fine with sonarqube 7.8.
Any insight would be appreciated.
I fixed this issue.
while running sonar-scanner command, I added the xmlReportPaths as a define property like sonar-scanner -Dsonar.coverage.jacoco.xmlReportPaths=tests/target/site/jacoco-aggregate/jacoco.xml,../tests/target/site/jacoco-aggregate/jacoco.xml
If your projects are set up as multi-module, you will have to feed the coverage report from each module to the last module that will run as part of the build (probably integration tests modules)
https://community.sonarsource.com/t/coverage-test-data-importing-jacoco-coverage-report-in-xml-format/12151
https://community.sonarsource.com/t/in-sonarqube-8-2-code-coverage-is-always-showing-0/21666
https://docs.sonarqube.org/latest/analysis/coverage/
https://stackoverflow.com/a/15535970
Following the steps mentioned in this example project by Sonar team helped me
https://github.com/SonarSource/sonar-scanning-examples/tree/master/sonarqube-scanner-maven/maven-multimodule
As you already followed these steps, one thing I was missing was the aggregated report was not generated in the last module and I was doing it in one module before that which was our integration test module. But there was one more deployment module in our case

How do I run JUnit tests in Gradle

I have JUnit tests that have a rest-assured dependency.
How can I run these in Gradle?
I have no idea what you mean by 'rest assured' tests but I'll assume you just want to run either JUnit or TestNG tests in gradle. You should really remove any maven references from your question to avoid confusion... this is a simple Gradle question and has nothing to do with Maven.
The following line in your build.gradle
apply plugin: java
Adds the java plugin to your build which adds appropriate test tasks to your build. Please see the java plugin documentation for configuring JUnit / TestNG

Cucumber with Gradle for Java

I use Gradle for building my project and I have some trouble between cucumber and gradle. For example:
I have a feature file, which I run with JUnit RunWith annotation. But if I want to run 1 scenario by tag, I write this:
-Dcucumber.options= --tags #1 #2 and try to run it.
But Gradle doesn't see this command and runs all tests. So, how can I correctly apply cucumber plugin into Gradle?
So, I found one way to do it. All we need is to use testCompile with JUnit, not cucumber-junit and all is right.

How to see unit test integration result of non-maven java project in sonar

How can see unit test integration result of non-maven java project in sonar. I have the latest version of Sonar installed and have latest java plugin. I think this java plugin comes along with jacaco and surefire. I used sonar-runner to analyse my project.
How can I run jacoco with my non maven java project and integrate the result with sonar.
You can check the following example to see how to get coverage result with JaCoCo and SonaQube runner: https://github.com/bellingard/multi-language-test
More specifically, look into the sonar-project.properties file and this section:
# For Java
sonar.junit.reportsPath=reports/java/surefire-reports
sonar.jacoco.reportPath=reports/java/jacoco.exec
sonar.binaries=target/classes

Categories

Resources