Skip to main content

How to use the Keploy Java SDK


  • Java 1.8+
  • Maven
  • Docker

Build configuration

Find the latest release of the Keploy Java SDK at maven central.

Add keploy-sdk as a dependency to your pom.xml:


or to build.gradle:

compile 'io.keploy:keploy-sdk:1.0.13'


Replace @SpringBootApplication with @SpringBootApplication(scanBasePackages = {"<your base package>", "io.keploy.servlet"}). in your main class.

  • Configure Environment Variables

    • APP_NAME (default APP_NAME = myApp)
    • APP_PORT (default APP_PORT = 6789)
    • KEPLOY_URL (default KEPLOY_URL = http://localhost:6789/api)
    • KEPLOY_MODE (default KEPLOY_MODE = record/test)
    • KTESTS_PATH (default test directory of your application)
    • DENOISE (default DENOISE = false) Note: By enabling denoise, it will filter out noisy fields for that testcases.
  • Generate testcases

    • To generate/capture TestCases set and run your application.
      1. Set KEPLOY_MODE = record
      2. Run your application.
      3. Make some API calls.
  • Run the testcases

    • Note: Before running tests stop the sample application.

      • Using environment variable

        1. Set KEPLOY_MODE = test (default "record")
        2. Run your application.
        3. You can also run the application with coverage to see the test coverage.
      • Using command line -

        1. Add below code in your testfile and run mvn test.

          public void TestKeploy() throws InterruptedException {

          CountDownLatch countDownLatch = HaltThread.getInstance().getCountDownLatch();
          new Thread(() -> {
          SamplesJavaApplication.main(new String[]{""});

        2. To get test coverage, in addition to above follow below instructions.

        3. Add maven-surefire-plugin to your pom.xml.


          <!-- <skipTests>true</skipTests> -->

        4. Add Jacoco plugin to your pom.xml.

          <!-- Sets the path to the file which contains the execution data. -->
          <!-- Sets the output directory for the code coverage report. -->
        5. Run your tests using command : mvn test.


There are 3 modes:

  • Record: Sets to record mode.
  • Test: Sets to test mode.
  • Off: Turns off all the functionality provided by the API

Note: KEPLOY_MODE value is case sensitive.