SonarQube code coverage for AEM project | Community
Skip to main content
New Participant
Apr 13, 2020 11:14 AM UTC

SonarQube code coverage for AEM project

Hi All,

 

We are using separate Sonarqube server and integrated with our application. Using that we are able to receive the code vulnerabilities properly. But Generating the Code Coverage is having issues. Currently we have integrated with Jacoco Plugin with SonarQube for  Code Coverage and we have installed Sonarqube with AEM rules plugin version 1.0.

 

We have done below changes in POM file -

 

POM Changes

 

<properties>

        <sonar.exclusions>**/*.js,**/*.xml,lib/*,packages/*,ui.galen/*,**/*.json,ui.npm/*,content/*</sonar.exclusions>

        <sonar.junit.reportPaths>bundle/target/surfire-reports</sonar.junit.reportPaths>

        <sonar.jacoco.reportPaths>bundle/target/jacoco.exec</sonar.jacoco.reportPaths>

</properties>

<plugin>

<groupId>org.jacoco</groupId>

<artifactId>jacoco-maven-plugin</artifactId>

<version>0.7.9</version>

<executions>

              <execution>

                             <id>pre-unit-test</id>

                             <goals>

                                           <goal>prepare-agent</goal>

                             </goals>

                             <configuration>

                                           <!-- Sets the path to the file which contains the execution data. -->

                                           <destFile>bundle/target/jacoco.exec</destFile>

                                           <excludes>

                                                          <exclude>**/*.js</exclude>

                                                          <exclude>**/*.xml</exclude>

                                                          <exclude>lib/*</exclude>

                                                          <exclude>packages/*</exclude>

                                                          <exclude>ui.galen/*</exclude>

                                                          <exclude>**/*.json</exclude>

                                                          <exclude>ui.npm/*</exclude>

                                                          <exclude>content/*</exclude>

                                           </excludes>

                                           <!-- Sets the name of the property containing the settings for JaCoCo runtime agent. -->

                                           <propertyName>surefireArgLine</propertyName>

                             </configuration>

              </execution>

              <!-- Ensures that the code coverage report for unit tests is created after unit tests have been run. -->

              <execution>

                             <id>post-unit-test</id>

                             <phase>test</phase>

                             <goals>

                                           <goal>report</goal>

                             </goals>

                             <configuration>

                                           <!-- Sets the path to the file which contains the execution data. -->

                                           <dataFile>bundle/target/jacoco.exec</dataFile>

                                           <!-- Sets the output directory for the code coverage report. -->

                                           <outputDirectory>bundle/target</outputDirectory>

                             </configuration>

              </execution>

              <execution>

                             <id>generate-code-coverage-report</id>

                             <phase>test</phase>

                             <goals>

                                             <goal>report</goal>

                             </goals>

              </execution>

</executions>

</plugin>

 

SONAR Command Used

 

mvn clean package sonar:sonar

 

With all these changes we are getting code coverage 0.0. So, please help me to resolve this issue.

 

Note: We are able to see the Code Coverage in IDE – Eclipse/IntelliJ. But not able to get the coverage report in sonarqube site. 

 

Thanks,

Debal

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

4 replies

arunpatidar
New Participant
Apr 13, 2020 2:08 PM UTC

you can run the code coverage using in built eclipse plugin and follow the code quality rules https://docs.adobe.com/content/help/en/experience-manager-cloud-manager/using/how-to-use/understand-your-test-results.html

 

Translate
Arun Patidar
Theo_Pendle
Level 8
Apr 13, 2020 12:08 PM UTC

Hi,

What do you mean by "plugin" exactly? 

If you mean special rules for AEM projects, you can find those (and installation instructions) here: https://github.com/Cognifide/AEM-Rules-for-SonarQube

If you are talking about an IDE plugin that will do the same analysis, then you are looking for this: https://www.sonarlint.org/intellij/. You can install that plugin in IntelliJ for example and then connect to a remote SonarQube server to make sure you are using the same rules in the IDE as Sonar will during static analysis.

Translate
Debal-DasAuthor
New Participant
Apr 13, 2020 1:23 PM UTC

Hi ,

 

Apologize for the confusion.

 

Please allow me to provide details here.

 

We are using separate Sonarqube server and integrated with our application. Using that we are able to receive the code vulnerabilities properly. But Generating the Code Coverage is having issues. Currently we have integrated with Jacoco Plugin with SonarQube for  Code Coverage and we have installed Sonarqube with AEM rules plugin version 1.0.

 

We have done below changes in POM file -

 

POM Changes

 

<properties>

        <sonar.exclusions>**/*.js,**/*.xml,lib/*,packages/*,ui.galen/*,**/*.json,ui.npm/*,content/*</sonar.exclusions>

        <sonar.junit.reportPaths>bundle/target/surfire-reports</sonar.junit.reportPaths>

        <sonar.jacoco.reportPaths>bundle/target/jacoco.exec</sonar.jacoco.reportPaths>

</properties>

<plugin>

<groupId>org.jacoco</groupId>

<artifactId>jacoco-maven-plugin</artifactId>

<version>0.7.9</version>

<executions>

              <execution>

                             <id>pre-unit-test</id>

                             <goals>

                                           <goal>prepare-agent</goal>

                             </goals>

                             <configuration>

                                           <!-- Sets the path to the file which contains the execution data. -->

                                           <destFile>bundle/target/jacoco.exec</destFile>

                                           <excludes>

                                                          <exclude>**/*.js</exclude>

                                                          <exclude>**/*.xml</exclude>

                                                          <exclude>lib/*</exclude>

                                                          <exclude>packages/*</exclude>

                                                          <exclude>ui.galen/*</exclude>

                                                          <exclude>**/*.json</exclude>

                                                          <exclude>ui.npm/*</exclude>

                                                          <exclude>content/*</exclude>

                                           </excludes>

                                           <!-- Sets the name of the property containing the settings for JaCoCo runtime agent. -->

                                           <propertyName>surefireArgLine</propertyName>

                             </configuration>

              </execution>

              <!-- Ensures that the code coverage report for unit tests is created after unit tests have been run. -->

              <execution>

                             <id>post-unit-test</id>

                             <phase>test</phase>

                             <goals>

                                           <goal>report</goal>

                             </goals>

                             <configuration>

                                           <!-- Sets the path to the file which contains the execution data. -->

                                           <dataFile>bundle/target/jacoco.exec</dataFile>

                                           <!-- Sets the output directory for the code coverage report. -->

                                           <outputDirectory>bundle/target</outputDirectory>

                             </configuration>

              </execution>

              <execution>

                             <id>generate-code-coverage-report</id>

                             <phase>test</phase>

                             <goals>

                                             <goal>report</goal>

                             </goals>

              </execution>

</executions>

</plugin>

 

SONAR Command Used

 

mvn clean package sonar:sonar

 

With all these changes we are getting code coverage 0.0. So, please help me to resolve this issue.

 

Thanks,

Debal

Translate
joerghoh
Employee
Apr 13, 2020 12:07 PM UTC

This question is not specific to AEM, but rather belongs to a SonarQube forum.

Translate