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. Installing java-SDK package
  • 2. Initializing SDK
  • 3. Verifying traffic is captured
  1. SETUP GUIDE
  2. Installation
  3. Integrate SDK

Java

How to add java sdk into your application

PreviousNode.js SDK with ESMNextStart a Test Run

Last updated 2 months ago

1. Installing java-SDK package

HyperTest's Maven packages are hosted on a GitHub public Maven registry. To install and use HyperTest's java-sdk package in your application, follow these steps:

  1. Create MVN_TOKEN - The Hypertest Team may share this with you, or you can generate your own personal access token by visiting .

  2. Add Repository Configuration in pom.xml

    1. Define Properties in pom.xml file

    2. Add the Repository in pom.xml file

  3. Add the HyperTest agent dependency to your project. You can check for the latest version on the .

  4. Install HyperTest's java-sdk package

Add the following content in your pom.xml

pom.xml
<dependencies>
    .
    .
    .
    
    <dependency>
        <groupId>co.hypertest</groupId>
        <artifactId>hypertest-agent</artifactId>
        <version>0.1.13-alpha.43</version>
    </dependency>
</dependencies>

<properties>
    <MVN_USERNAME>hypertestcustomers/[YOUR_GITHUB_USERNAME]</MVN_USERNAME>
    <MVN_TOKEN>[YOUR_MVN_TOKEN]</MVN_TOKEN>
</properties>

<repositories>
    <repository>
        <id>github</id>
        <url>https://${MVN_USERNAME}:${MVN_TOKEN}@maven.pkg.github.com/hypertestco/autoqa_v2_java</url>
    </repository>
</repositories>

Run the following command

mvn clean install

2. Initializing SDK

2.1 Adding SDK in code

  • Initalize the HyperTest Java SDK in the public static void main method of your service. This must be the first thing in your main method.

This needs to happen as early in your app as possible.

new HypertestAgentBuilder("<HT_SERVICE_ID>", "<YOUR_SERVICE_NAME>",  "<API_KEY>",
 "<LOGGER_URL>", "<APPLICATION_CLASS>").build();

2.2 Mark app as ready

Call this method after SpringApplication.run when the app is ready to receive traffic, it indicates that tests can be started (This is important ONLY FOR REPLAY mode).

// Rest Application code...
System.setProperty(APP_STATUS, UP_STATUS);

To enable hypertest, set the HT_MODE env variable to RECORD and start your app

3. Verifying traffic is captured

Start sending http requests on your app running with hypertest sdk.

You should start seeing requests under All requests section on the dashboard

<HT_SERVICE_ID> is the identifier that we created in

GitHub Personal Access Tokens
HyperTest Java SDK
Adding your first service section