0

I have been assigned a task where I want to generate the code coverage report of web application execution (development code) when a manual or automation test script is executed, I have to identify (using any tool) what percent of development code has been executed against that particular action. After doing my RnD, I found that this can be achieved using JaCoCo (Java Code Coverage). JaCoCo uses class file instrumentation to record execution coverage data. Class files are instrumented on-the-fly using a Java agent. I have used the java command in the java agent flag.

Points to Mention

  • Application front-end is Angular, backend is Java/BPM and is deployed on JBoss Server.
  • Backend code contain multiple modules.
  • Testcase are executed from my local machines, that hits the application deployed on the server.

APPROACH

  1. I have added the below mentioned command in /app/JBoss-EAP-7.2/bin/standalone.sh file because this is the file that is executed when the server starts.
Javaagent:<path_to>/jacocoagent.jar=classdumpdir=<path_to>/jacocoClassDump, destfile=<path_to>/jacocoST.exec
  1. Restart JBoss server. [After this jacocoST.exec file is created in the respective folder]
  2. Run automated testcase using maven on my local machine.
  3. Stop the JBoss server. [so that jacocoST.exec file is updated]
  4. Run the command:
 java -jar <path_to>/jacococli.jar report <path_to>/jacoco-it.exec --  classfiles=<path_to>/jacocoClassDump --html /app/Jacocoreport --xml                                                                                                              cov.xml

The above steps show error Can't add different class with same name

Why do I get the error "Can't add different class with same name"?

The FAQ that I’ve come across from JaCoCo Official Documentation

For coverage report generation all classes within a group must have unique names. You get this error during report generation if JaCoCo is supplied with multiple different class files with the same name. To fix this remove those duplicate classes or create separate reports or report groups for each version.

The main problem is the error which I am getting. According to FAQ, they suggest to delete duplicate files but there are no duplicate class files (each class files has unique number at the end).If somebody has done such work so please guide me, Are the steps which I followed right?

  • Please don't [delete](https://stackoverflow.com/questions/75016268/web-application-code-coverage-using-jacoco) and repost your closed questions – Alon Eitan Jan 05 '23 at 11:11
  • I have corrected the issues that were previously mentioned. Nothing has been mentioned against the question. Why cant I repost it @AlonEitan? – Areeba Naseer Jan 05 '23 at 11:16
  • 1
    It's not recommended because it can lead to a [question ban](https://stackoverflow.com/help/question-bans) – Alon Eitan Jan 05 '23 at 11:19
  • I will keep this in mind next time. For now, it will be a great help if you could answer my question – Areeba Naseer Jan 05 '23 at 11:58
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Kunal Varpe Jan 05 '23 at 14:54

0 Answers0