Skip to content

Commit 33a1cd3

Browse files
authored
feat: update test coverage page (#711)
Signed-off-by: Achanandhi-M <[email protected]>
1 parent 6a8ec1a commit 33a1cd3

File tree

4 files changed

+115
-27
lines changed

4 files changed

+115
-27
lines changed

versioned_docs/version-3.0.0/server/sdk-installation/go.md

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
id: go
3-
title: Merge Unit Test Coverage Data
3+
title: Merge Unit and Keploy Test Coverage Data
44
sidebar_label: Go
55
tags:
66
- go
@@ -18,17 +18,15 @@ keyword:
1818
- Go Test
1919
---
2020

21-
import WhatAreKeployFeatures from './index.md'
22-
23-
<WhatAreKeployFeatures/>
24-
2521
## 🛠️ Language Specific Requirements
2622

27-
| Programming Language | Prerequisites |
28-
| :------------------: | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
29-
| go | 1. The application should have a graceful shutdown to stop the API server on `SIGTERM` or `SIGINT` signals. Refer [appendix](#graceful-shutdown) for basic implementation of graceful shutdown function. <br/> 2. The go binary should be built with `-cover` flag. |
23+
There are two requirements to get coverage for Go: first, you need to perform a graceful shutdown, and second, you must build the binary using the `-cover` flag. Once that’s done, run `keploy test`.
24+
25+
| Programming Language | Prerequisites |
26+
| :------------------: | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
27+
| go | 1. The application should have a graceful shutdown to stop the API server on `SIGTERM` or `SIGINT` signals. Refer below code for basic implementation of graceful shutdown function. <br/> 2. The go binary should be built with `-cover` flag. |
3028

31-
## Graceful Shutdown
29+
## 1. Graceful Shutdown
3230

3331
It is important that the application is shutdown gracefully. In case of Golang, function for graceful shutdown:
3432

@@ -60,14 +58,35 @@ func main() {
6058
}
6159
```
6260

63-
## Usage
61+
## 2. Usage
6462

6563
For keploy test coverage the binary must built with `-cover` flag:
6664

6765
```go
6866
go build -cover
6967
```
7068

69+
Once it has been done, run keploy test command:
70+
71+
```
72+
keploy test -c "your_application_command"
73+
```
74+
75+
After successful execution of this command, A coverage report would be generated inside the test-run folder of keploy/reports.
76+
77+
```
78+
keploy
79+
├── reports
80+
│ └── test-run-0
81+
│ ├── coverage.yaml
82+
│ └── test-set-0-report.yaml
83+
└── test-set-0
84+
├── mocks.yaml
85+
└── tests
86+
├── test-1.yaml
87+
└── test-2.yaml
88+
```
89+
7190
To get the coverage data for unit tests :
7291

7392
```go

versioned_docs/version-3.0.0/server/sdk-installation/java.md

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
id: java
3-
title: Merge Unit Test Coverage Data
3+
title: Merge Unit and Keploy Test Coverage Data
44
sidebar_label: Java
55
tags:
66
- java
@@ -18,10 +18,6 @@ keyword:
1818
- Junit
1919
---
2020

21-
import WhatAreKeployFeatures from './index.md'
22-
23-
<WhatAreKeployFeatures/>
24-
2521
## 🛠️ Language Specific Requirements
2622

2723
| Programming Language | Prerequisites |
@@ -111,6 +107,27 @@ You will need to add the following plugins in `pom.xml` file of your application
111107
</build>
112108
```
113109

110+
Once it has been done, run keploy test command:
111+
112+
```
113+
keploy test -c "your_application_command"
114+
```
115+
116+
After successful execution of this command, A coverage report would be generated inside the test-run folder of keploy/reports.
117+
118+
```
119+
keploy
120+
├── reports
121+
│ └── test-run-0
122+
│ ├── coverage.yaml
123+
│ └── test-set-0-report.yaml
124+
└── test-set-0
125+
├── mocks.yaml
126+
└── tests
127+
├── test-1.yaml
128+
└── test-2.yaml
129+
```
130+
114131
Now, To get the combined report as well as coverage report for your unit tests, Run
115132

116133
```bash

versioned_docs/version-3.0.0/server/sdk-installation/javascript.md

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
id: javascript
3-
title: Merge Unit Test Coverage Data
3+
title: Merge Unit and Keploy Test Coverage Data
44
sidebar_label: Javascript
55
tags:
66
- javascript
@@ -21,10 +21,6 @@ keywords:
2121
- Typescript
2222
---
2323

24-
import WhatAreKeployFeatures from './index.md'
25-
26-
<WhatAreKeployFeatures/>
27-
2824
## 🛠️ Language Specific Requirements
2925

3026
| Programming Language | Prerequisites |
@@ -47,8 +43,37 @@ Update the `package.json` file that runs the application:
4743
}
4844
```
4945

46+
#### Install nyc:
47+
48+
```
49+
npm i nyc
50+
```
51+
5052
In the test script, the --coverage flag triggers report generation for Jest. For other testing frameworks like Mocha, Intern, or Tap, you will need to use their respective coverage tools.
5153

54+
#### Run keploy test command:
55+
56+
Once it has been done, run keploy test command:
57+
58+
```
59+
keploy test -c "your_application_command"
60+
```
61+
62+
After successful execution of this command, A coverage report would be generated inside the test-run folder of keploy/reports.
63+
64+
```
65+
keploy
66+
├── reports
67+
│ └── test-run-0
68+
│ ├── coverage.yaml
69+
│ └── test-set-0-report.yaml
70+
└── test-set-0
71+
├── mocks.yaml
72+
└── tests
73+
├── test-1.yaml
74+
└── test-2.yaml
75+
```
76+
5277
To generate coverage report for your unit tests, Run:
5378

5479
```bash

versioned_docs/version-3.0.0/server/sdk-installation/python.md

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
id: python
3-
title: Merge Unit Test Coverage Data
3+
title: Merge Unit and Keploy Test Coverage Data
44
sidebar_label: Python
55
tags:
66
- python
@@ -16,16 +16,45 @@ keyword:
1616
- Pytest
1717
---
1818

19-
import WhatAreKeployFeatures from './index.md'
20-
21-
<WhatAreKeployFeatures/>
22-
2319
| Programming Language | Prerequisites |
2420
| :------------------: | :------------------------------------------------------------------------ |
2521
| python | [Python 3 and above](https://www.python.org/downloads/) <br/> coverage.py |
2622

2723
## Usage
2824

25+
#### First install Coverage library:
26+
27+
```
28+
pip install coverage
29+
```
30+
31+
For Python, Keploy will automatically generate the coverage report after you run the command below.
32+
33+
```
34+
keploy test -c "your_application_command"
35+
```
36+
37+
If you’re running with **Unicorn**, use the following command:
38+
39+
```
40+
keploy test -c "python -m uvicorn application.main:app --reload" --delay 10
41+
```
42+
43+
After successful execution of this command, A coverage report would be generated inside the test-run folder of keploy/reports.
44+
45+
```
46+
keploy
47+
├── reports
48+
│ └── test-run-0
49+
│ ├── coverage.yaml
50+
│ └── test-set-0-report.yaml
51+
└── test-set-0
52+
├── mocks.yaml
53+
└── tests
54+
├── test-1.yaml
55+
└── test-2.yaml
56+
```
57+
2958
To get the coverage data for your unit tests:
3059

3160
```sh
@@ -34,8 +63,6 @@ coverage run --data-file=.coverage.unit test_program.py
3463

3564
Here, test_program.py is the unit test program you want to run, and --data-file is set to .coverage.unit because, by default, raw coverage data would be written to .coverage which is where coverage data for keploy tests is present, so to avoid overwriting we pass a new file through data-file flag.
3665

37-
> Note: If you face any problems with running the coverage library, you can refer to the documentation.
38-
3966
### Combine And Get Report
4067

4168
To combine the coverage from the unit tests, and Keploy's API tests we can use the command below:

0 commit comments

Comments
 (0)