diff --git a/.vscode/settings.json b/.vscode/settings.json
new file mode 100644
index 00000000..e0f15db2
--- /dev/null
+++ b/.vscode/settings.json
@@ -0,0 +1,3 @@
+{
+ "java.configuration.updateBuildConfiguration": "automatic"
+}
\ No newline at end of file
diff --git a/common/pom.xml b/common/pom.xml
index b9a3250b..d28e3e0e 100644
--- a/common/pom.xml
+++ b/common/pom.xml
@@ -21,5 +21,17 @@
1.0.0-SNAPSHOT
compile
+
+
+ org.yaml
+ snakeyaml
+ 1.25
+
+
+
+ org.jacoco
+ org.jacoco.core
+ 0.8.7
+
\ No newline at end of file
diff --git a/common/src/main/java/io/keploy/utils/CoverageHandler.java b/common/src/main/java/io/keploy/utils/CoverageHandler.java
new file mode 100644
index 00000000..ab25fb31
--- /dev/null
+++ b/common/src/main/java/io/keploy/utils/CoverageHandler.java
@@ -0,0 +1,185 @@
+package io.keploy.utils;
+
+import java.io.File;
+import java.io.InputStream;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.net.InetAddress;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+
+import org.jacoco.core.analysis.Analyzer;
+import org.jacoco.core.analysis.CoverageBuilder;
+import org.jacoco.core.analysis.IClassCoverage;
+import org.jacoco.core.analysis.ICounter;
+import org.jacoco.core.tools.ExecFileLoader;
+import org.jacoco.core.data.ExecutionDataWriter;
+import org.jacoco.core.runtime.RemoteControlReader;
+import org.jacoco.core.runtime.RemoteControlWriter;
+import org.yaml.snakeyaml.DumperOptions;
+import java.net.Socket;
+import org.yaml.snakeyaml.Yaml;
+import org.yaml.snakeyaml.reader.UnicodeReader;
+
+
+
+public class CoverageHandler {
+ private static final String ADDRESS = "localhost";
+ public static String Line_Path = "";
+
+
+ private static final int PORT = 36320;
+
+ public static void getCoverage(String keploy_test_id) throws IOException, InterruptedException {
+
+ try {
+ execWriter(keploy_test_id);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ try {
+ execReader(keploy_test_id);
+ } catch (IOException e) {
+ e.printStackTrace(); // Example: print the stack trace
+ }
+
+ }
+
+public static void execWriter(String keploy_test_id) throws IOException {
+ File directory = new File(
+ System.getProperty("user.dir") + "/target");
+ File file = new File(directory, "jacoco-client" + keploy_test_id + ".exec");
+// File file = new File(directory, "jacoco-client.exec");
+
+ final FileOutputStream localFile = new FileOutputStream(file);
+
+ final ExecutionDataWriter localWriter = new ExecutionDataWriter(
+ localFile);
+
+ // Open a socket to the coverage agent:
+ final Socket socket = new Socket(InetAddress.getByName(ADDRESS), PORT);
+ final RemoteControlWriter writer = new RemoteControlWriter(
+ socket.getOutputStream());
+ final RemoteControlReader reader = new RemoteControlReader(
+ socket.getInputStream());
+ reader.setSessionInfoVisitor(localWriter);
+ reader.setExecutionDataVisitor(localWriter);
+
+ // Send a dump command and read the response:
+ writer.visitDumpCommand(true, true);
+ if (!reader.read()) {
+ throw new IOException("Socket closed unexpectedly.");
+ }
+
+ socket.close();
+ localFile.close();
+}
+private static void execReader(String keploy_test_id) throws IOException {
+ // Together with the original class definition we can calculate coverage
+ // information:
+ System.out.println("------------------------------------------");
+ ExecFileLoader loader = new ExecFileLoader();
+
+ List