You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When developing or maintaining a software, it is common for test suites to grow in size. This often results in redundancy, as many test cases cover the same functions or scenarios. This is where Test Deduplication comes into play.
28
28
29
-
It simplifies the testing process by removing redundant test cases, which saves time and resources while keeping the testcases which adds value to the overall coverage of the application.
29
+
It simplifies the testing process by identifying redundant test cases, which saves time and resources while keeping the testcases that add value to the overall coverage of the application.
30
30
31
31
## Usage 🛠️
32
32
33
-
To detect duplicate tests, simply run the below command, like so:
33
+
To collect coverage for dynamic deduplication, run:
34
34
35
35
```bash
36
36
keploy test -c "docker compose up" --containerName containerName --dedup
37
37
```
38
38
39
39
### For Golang Applications
40
40
41
-
#### 1. Pre-requisite
41
+
**1. Pre-requisite**
42
42
43
43
Install the `keploy/go-sdk/v3/keploy` : -
44
44
@@ -52,15 +52,15 @@ Add the following on top of your main application file : -
52
52
import _ "github.com/keploy/go-sdk/v3/keploy"
53
53
```
54
54
55
-
#### 2. Build Configuration
55
+
**2. Build Configuration**
56
56
57
57
Update the `go build` command in your Dockerfile (or native build script) to include coverage flags. These are required for deduplication to calculate coverage accurately.
58
58
59
59
```bash
60
60
RUN go build -cover -covermode=atomic -coverpkg=./... -o /app/main .
61
61
```
62
62
63
-
#### 3. Dockerfile Configuration (Important for Docker Users)
63
+
**3. Dockerfile Configuration (Important for Docker Users)**
64
64
65
65
If you are using a multi-stage Docker build (e.g., building in one stage and running in a slim image), you **must** ensure the Go toolchain and `go.mod` files are preserved in the final runtime image. The deduplication feature requires access to the Go runtime to map coverage data correctly.
66
66
@@ -87,7 +87,7 @@ ENV GOMOD=/app/go.mod
87
87
88
88
> **Note:** If you face issues with toolchain downloads in restricted environments, you may also need to set `ENV GOTOOLCHAIN=local` and configure your `GOPROXY` in the Dockerfile.
89
89
90
-
#### 4. Run Deduplication
90
+
**4. Run Deduplication**
91
91
92
92
For Docker, run:
93
93
@@ -131,7 +131,7 @@ Add the Keploy Java SDK to your application:
131
131
</dependency>
132
132
```
133
133
134
-
For Spring Boot applications, register the Keploy middleware in your main class:
134
+
For Spring Boot 2 or other `javax.servlet`applications, register the Keploy middleware in your main class:
135
135
136
136
```java
137
137
importio.keploy.servlet.KeployMiddleware;
@@ -144,6 +144,14 @@ public class App {
144
144
}
145
145
```
146
146
147
+
For Spring Boot 3, Jakarta EE applications, other frameworks, or custom launchers, start the agent during application startup:
148
+
149
+
```java
150
+
importio.keploy.dedup.KeployDedupAgent;
151
+
152
+
KeployDedupAgent.start();
153
+
```
154
+
147
155
Java dynamic deduplication uses JaCoCo runtime coverage. The SDK reads coverage in-process via JaCoCo's runtime API (`org.jacoco.agent.rt.RT.getAgent()`), so attaching the JaCoCo Java agent is enough: no TCP server flags, no `--pass-through-ports`.
148
156
149
157
```bash
@@ -200,7 +208,7 @@ For hardened Docker runs, the Java dedup sample is validated with a non-root run
0 commit comments