From 378a573762dd7e9e12dc71efd3959fcd51f435bd Mon Sep 17 00:00:00 2001 From: Gourav kumar <44055698+gouravkrosx@users.noreply.github.com> Date: Fri, 19 Apr 2024 00:27:12 +0530 Subject: [PATCH] feat: add closeDelay to support async calls coverage (#177) * feat: add closeDelay to support async calls coverage Signed-off-by: gouravkrosx * chore: format Signed-off-by: gouravkrosx --------- Signed-off-by: gouravkrosx --- v2/src/main/java/io/keploy/Keploy.java | 27 ++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/v2/src/main/java/io/keploy/Keploy.java b/v2/src/main/java/io/keploy/Keploy.java index 5aae90c..cfd4c8c 100644 --- a/v2/src/main/java/io/keploy/Keploy.java +++ b/v2/src/main/java/io/keploy/Keploy.java @@ -30,12 +30,13 @@ public static class RunOptions { private int port; private String path; private String appCmd; + private int closeDelay; public RunOptions() { - this(10, false, 6789, "."); + this(10, false, 6789, ".", 0); } - public RunOptions(int delay, boolean debug, int port, String path) { + public RunOptions(int delay, boolean debug, int port, String path,int closeDelay) { if (delay < 0) { throw new IllegalArgumentException("Delay must be a positive integer."); } @@ -52,6 +53,11 @@ public RunOptions(int delay, boolean debug, int port, String path) { throw new IllegalArgumentException("Port must be a positive integer."); } this.port = port; + + if (closeDelay < 0) { + throw new IllegalArgumentException("CloseDelay must be a positive integer."); + } + this.closeDelay = closeDelay; } // Getters and setters @@ -66,6 +72,17 @@ public void setDelay(int delay) { this.delay = delay; } + public int getCloseDelay() { + return closeDelay; + } + + public void setCloseDelay(int closeDelay) { + if (closeDelay < 0) { + throw new IllegalArgumentException("CloseDelay must be a positive integer."); + } + this.closeDelay = closeDelay; + } + public boolean isDebug() { return debug; } @@ -539,6 +556,12 @@ public static void runTests(String jarPath, RunOptions runOptions) { waitForTestRunCompletion(testRunId, testSet, appId); try { + if (runOptions.getCloseDelay() > 0){ + logger.info("waiting for {} seconds before closing the application in order to get coverage of async calls", runOptions.getCloseDelay()); + //wait for closeDelay in order to get coverage of async calls as well + Thread.sleep(runOptions.getCloseDelay() * 1000); + } + Keploy.FindCoverage(testSet); Thread.sleep(5000);