Hypertest v2 Docs
HyperTest
  • Overview
    • How It Works?
  • SETUP GUIDE
    • Installation
      • Deploy HyperTest Server
      • Creating your first User
      • Adding your first service
      • Integrate SDK
        • Node.js
          • Node.js SDK with CJS
          • Node.js SDK with ESM
        • Java
    • Start a Test Run
      • CLI Login
      • Type References
      • Java
  • Interpreting Test Results
    • Test Results
    • Understanding Results Categories
    • Mock Not Found
    • AI Match Mocks
    • Accepting Changes
  • USER GUIDES
    • Node.js SDK
      • Limit memory usage
      • Supported NPM packages
      • Mock Dependencies Manually
      • Unmocking/Passing Through
      • Sampling and blocking requests
      • Manage Global Variables
      • Mocking Environment Variables
      • Tags
      • Set HTTP path patterns
      • Discard a test case(Request) while recording
      • Set Git Commit Hash
      • Code coverage based features
        • Continuous Coverage
        • Updating test coverage
        • Running post test deduplication
        • Only testing modified requests
        • Ignore differences for unmodified requests
      • Experimental flags
      • Manual Request
      • Only testing modified requests
      • Server hooks
    • Java SDK
      • Sampling and blocking requests
      • Mock Dependencies Manually
      • Tags
      • Unmocking/Passing Through
      • Code Coverage Setup and Report Generation
      • Supported Java packages
    • Build your own Docker Image
    • CLI Config
    • Ignoring Differences
      • Type References for Filter functions
  • Impact Features
    • Fast Mode
    • Code Coverage Report
    • Delete Recorded Requests
    • Inter Service Testing
  • Release History
    • Slack Integration
    • Version History
Powered by GitBook
On this page
  1. USER GUIDES
  2. Java SDK

Code Coverage Setup and Report Generation

PreviousUnmocking/Passing ThroughNextSupported Java packages

Last updated 2 months ago

Follow these steps to set up and view the code coverage report for your application:

  1. Navigate to the root directory of your application

  2. Download the JaCoCo library and extract it:

    1. Using Browser ()

    2. or Using Terminal

      1. For Linux OS

      2. For Windows OS

curl -L -o jacoco-0.8.12.zip https://search.maven.org/remotecontent?filepath=org/jacoco/jacoco/0.8.12/jacoco-0.8.12.zip
unzip jacoco-0.8.12.zip -d jacoco-0.8.12
mkdir jars
mv jacoco-0.8.12/lib/* jars
curl -L -o jacoco-0.8.12.zip https://search.maven.org/remotecontent?filepath=org/jacoco/jacoco/0.8.12/jacoco-0.8.12.zip
tar -xf jacoco-0.8.12.zip -C jacoco-0.8.12
mkdir jars
move jacoco-0.8.12\lib\* jars
  1. Update .htTestConf.js 's appStartCommandArgs

appStartCommandArgs: [
"-Dspring-boot.run.jvmArguments=-javaagent:jars/jacocoagent.jar=output=file,destfile=./coverage.exec",
"spring-boot:run"]
  1. Execute the application in Replay mode

  2. Generate and view coverage report

java -jar jars/jacococli.jar report ./coverage.exec \
    --classfiles target/classes \
    --sourcefiles src/main/java \
    --html report
  1. To view the code coverage results, open the following report/index.html file.

Link