Skip to content

Commit

Permalink
feat: add closeDelay to support async calls coverage (#177)
Browse files Browse the repository at this point in the history
* feat: add closeDelay to support async calls coverage

Signed-off-by: gouravkrosx <gouravgreatkr@gmail.com>

* chore: format

Signed-off-by: gouravkrosx <gouravgreatkr@gmail.com>

---------

Signed-off-by: gouravkrosx <gouravgreatkr@gmail.com>
  • Loading branch information
gouravkrosx authored Apr 18, 2024
1 parent c514956 commit 378a573
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions v2/src/main/java/io/keploy/Keploy.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
}
Expand All @@ -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
Expand All @@ -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;
}
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 378a573

Please sign in to comment.