how to use jacoco.exec report

前端 未结 10 1326
感情败类
感情败类 2020-12-07 18:30

I generated a code coverage report from jacoco, which is jacoco.exec. But I don\'t know how to use it ...

The way I generated it is through command line:

相关标签:
10条回答
  • 2020-12-07 18:51

    I think the report will have already been generated. Look in the folder target/site/jacoco.

    This provides target/site/jacoco/jacoco.csv, which is some raw text that you can interpret relatively easily -- maybe import into a spreadsheet

    Most people will want target/site/jacoco/index.html, which is a report in web-page form.


    If you aren't seeing these reports, try explicitly requesting them and see if any clues are provided...

    mvn clean test jacoco:report
    
    0 讨论(0)
  • 2020-12-07 18:53

    In IntelliJ Idea from the menu select Analyze > Show Coverage data. In the new window press the + button and select your .exec file. The test coverage results will appear in the editor Coverage tab.

    Update:

    In the latest version of Intellij Idea the menu has been moved to Run > Show Code Coverage Data

    0 讨论(0)
  • 2020-12-07 18:54

    terminal: mvn install jacoco:report for maven project with jacoco plugins

    0 讨论(0)
  • 2020-12-07 18:56

    Jacoco provides a command line lib to process jacoco.exec data: Jacoco cli doc

    After you install Jacoco, you can generate report with following command:

    java -jar lib/jacococli.jar report jacoco.exec \
    --html ./report \
    --sourcefiles [path/to/your/source/files] \
    --classfiles [path/to/your/class/files]
    
    0 讨论(0)
  • 2020-12-07 18:56

    To view this in IntelliJ Idea, from the menu bar, select Run > Show Code Coverage Data. In the new window (Choose Coverage Suite to Display), press the + button and select your .exec file. The test coverage results will appear in the editor Coverage tab.

    To generate the Coverage Report files for the above .exec file, select Run > Generate Coverage Report. Then select your output directory and click on Save. Your reports would be generated to the selected folder. Open the index.html file in the folder to view the results on the browser. I am using IntelliJ IDEA 2019.3.4 (Community Edition)

    0 讨论(0)
  • 2020-12-07 19:02

    we can push jacoco exec report (created as part of maven build) to the sonar(qube) server using maven-sonar-plugin's target, sonar:sonar

    mvn clean install sonar:sonar -Dsonar.host.url=http://:9000 -Dsonar.projectKey= -Dsonar.branch= -Dsonar.login= -Dsonar.password=

    sonar.projectKey and sonar.branch properties value can be retrieved from corresponding project created in sonarqube.

    0 讨论(0)
提交回复
热议问题