Skip to main content
Version: 1.0.0

Replay Tests & Mocks for Java (v1.0.0)

To run KTests and KMocks you can follow any one of these methods:

Method 1

Set Environment Variable KEPLOY_MODE

export KEPLOY_MODE="test"

Run application and find test report summary on the Keploy Server Logs and detailed test report in directory where Keploy Server is running.

Test report summary

Method 2 [preferred]

Testing using Unit Test File

  • Add below code in your unit testfile, say, in test/java directory.
public void TestKeploy() throws InterruptedException {

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

  • Run mvn test

Method 3

Get Test-Coverage with Surgefire

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

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

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

  • 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. -->
  • Run your tests using command : mvn test.

Method 4

Run Tests in CI/CD

After following METHOD 2 above ^, Keploy will be integrated to junit. If you already have junit no changes are required in the CI/CD pipeline.