Getting Error : Build Failed,what is the step to get code coverage using Maven, any plugin to add?

I am Trying to achieve code coverage for Azure devops project, I have added Maven Task but, its getting failed and message is build failed.I have added following tasks:

What should I add, Jacoco plugin? And what fields shall I fill so that I get code coverage for my app?

Hi,

I’m confused by your screenshot. It shows a ‘Prepare analysis’ task, but you also mentioned Maven. What languages are in your project?

 
Ann

This is for Sonarqube code coverage. Selenium Test cases, Java

Hi,

First, you’ll need to convert your Selenium test results to something SonarQube can read, presumably the Generic Test Coverage format.

Then you’ll need to feed that report into analysis, with either a pom property, or a commandline argument, like -D sonar.coverageReportPaths=[path to report].

Backing up a bit, since you have a Maven project, you only need Maven analysis. You don’t need to use the Prepare and end tasks. More details in the docs.

 
HTH,
Ann

I want to get code coverage using maven task, since selenium is being utilized in this project. So, I have added the pom.xml in maven task, and selected the code coverage option. Also, I have added jacoco property,jacoco maven plugin, and following from this article( Code Coverage with SonarQube and JaCoCo | Baeldung). Please let me know how to generate code coverage for this project.

Hi,

Before analysis, you need to generate a coverage report SonarQube can read. Then you need to feed that report into analysis. If it’s a JaCoCo report, it should be picked up automatically.

 
HTH,
Ann