Skip to content

Commit 378a573

Browse files
authored
feat: add closeDelay to support async calls coverage (#177)
* feat: add closeDelay to support async calls coverage Signed-off-by: gouravkrosx <[email protected]> * chore: format Signed-off-by: gouravkrosx <[email protected]> --------- Signed-off-by: gouravkrosx <[email protected]>
1 parent c514956 commit 378a573

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

v2/src/main/java/io/keploy/Keploy.java

+25-2
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,13 @@ public static class RunOptions {
3030
private int port;
3131
private String path;
3232
private String appCmd;
33+
private int closeDelay;
3334

3435
public RunOptions() {
35-
this(10, false, 6789, ".");
36+
this(10, false, 6789, ".", 0);
3637
}
3738

38-
public RunOptions(int delay, boolean debug, int port, String path) {
39+
public RunOptions(int delay, boolean debug, int port, String path,int closeDelay) {
3940
if (delay < 0) {
4041
throw new IllegalArgumentException("Delay must be a positive integer.");
4142
}
@@ -52,6 +53,11 @@ public RunOptions(int delay, boolean debug, int port, String path) {
5253
throw new IllegalArgumentException("Port must be a positive integer.");
5354
}
5455
this.port = port;
56+
57+
if (closeDelay < 0) {
58+
throw new IllegalArgumentException("CloseDelay must be a positive integer.");
59+
}
60+
this.closeDelay = closeDelay;
5561
}
5662

5763
// Getters and setters
@@ -66,6 +72,17 @@ public void setDelay(int delay) {
6672
this.delay = delay;
6773
}
6874

75+
public int getCloseDelay() {
76+
return closeDelay;
77+
}
78+
79+
public void setCloseDelay(int closeDelay) {
80+
if (closeDelay < 0) {
81+
throw new IllegalArgumentException("CloseDelay must be a positive integer.");
82+
}
83+
this.closeDelay = closeDelay;
84+
}
85+
6986
public boolean isDebug() {
7087
return debug;
7188
}
@@ -539,6 +556,12 @@ public static void runTests(String jarPath, RunOptions runOptions) {
539556
waitForTestRunCompletion(testRunId, testSet, appId);
540557

541558
try {
559+
if (runOptions.getCloseDelay() > 0){
560+
logger.info("waiting for {} seconds before closing the application in order to get coverage of async calls", runOptions.getCloseDelay());
561+
//wait for closeDelay in order to get coverage of async calls as well
562+
Thread.sleep(runOptions.getCloseDelay() * 1000);
563+
}
564+
542565
Keploy.FindCoverage(testSet);
543566

544567
Thread.sleep(5000);

0 commit comments

Comments
 (0)