Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 29 additions & 10 deletions versioned_docs/version-3.0.0/server/sdk-installation/go.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
id: go
title: Merge Unit Test Coverage Data
title: Merge Unit and Keploy Test Coverage Data
sidebar_label: Go
tags:
- go
Expand All @@ -18,17 +18,15 @@ keyword:
- Go Test
---

import WhatAreKeployFeatures from './index.md'

<WhatAreKeployFeatures/>

## 🛠️ Language Specific Requirements

| Programming Language | Prerequisites |
| :------------------: | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| 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. |
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`.

| Programming Language | Prerequisites |
| :------------------: | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 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. |

## Graceful Shutdown
## 1. Graceful Shutdown

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

Expand Down Expand Up @@ -60,14 +58,35 @@ func main() {
}
```

## Usage
## 2. Usage

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

```go
go build -cover
```

Once it has been done, run keploy test command:

```
keploy test -c "your_application_command"
```

After successful execution of this command, A coverage report would be generated inside the test-run folder of keploy/reports.

```
keploy
├── reports
│ └── test-run-0
│ ├── coverage.yaml
│ └── test-set-0-report.yaml
└── test-set-0
├── mocks.yaml
└── tests
├── test-1.yaml
└── test-2.yaml
```

To get the coverage data for unit tests :

```go
Expand Down
27 changes: 22 additions & 5 deletions versioned_docs/version-3.0.0/server/sdk-installation/java.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
id: java
title: Merge Unit Test Coverage Data
title: Merge Unit and Keploy Test Coverage Data
sidebar_label: Java
tags:
- java
Expand All @@ -18,10 +18,6 @@ keyword:
- Junit
---

import WhatAreKeployFeatures from './index.md'

<WhatAreKeployFeatures/>

## 🛠️ Language Specific Requirements

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

Once it has been done, run keploy test command:

```
keploy test -c "your_application_command"
```

After successful execution of this command, A coverage report would be generated inside the test-run folder of keploy/reports.

```
keploy
├── reports
│ └── test-run-0
│ ├── coverage.yaml
│ └── test-set-0-report.yaml
└── test-set-0
├── mocks.yaml
└── tests
├── test-1.yaml
└── test-2.yaml
```

Now, To get the combined report as well as coverage report for your unit tests, Run

```bash
Expand Down
35 changes: 30 additions & 5 deletions versioned_docs/version-3.0.0/server/sdk-installation/javascript.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
id: javascript
title: Merge Unit Test Coverage Data
title: Merge Unit and Keploy Test Coverage Data
sidebar_label: Javascript
tags:
- javascript
Expand All @@ -21,10 +21,6 @@ keywords:
- Typescript
---

import WhatAreKeployFeatures from './index.md'

<WhatAreKeployFeatures/>

## 🛠️ Language Specific Requirements

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

#### Install nyc:

```
npm i nyc
```

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.

#### Run keploy test command:

Once it has been done, run keploy test command:

```
keploy test -c "your_application_command"
```

After successful execution of this command, A coverage report would be generated inside the test-run folder of keploy/reports.

```
keploy
├── reports
│ └── test-run-0
│ ├── coverage.yaml
│ └── test-set-0-report.yaml
└── test-set-0
├── mocks.yaml
└── tests
├── test-1.yaml
└── test-2.yaml
```

To generate coverage report for your unit tests, Run:

```bash
Expand Down
41 changes: 34 additions & 7 deletions versioned_docs/version-3.0.0/server/sdk-installation/python.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
id: python
title: Merge Unit Test Coverage Data
title: Merge Unit and Keploy Test Coverage Data
sidebar_label: Python
tags:
- python
Expand All @@ -16,16 +16,45 @@ keyword:
- Pytest
---

import WhatAreKeployFeatures from './index.md'

<WhatAreKeployFeatures/>

| Programming Language | Prerequisites |
| :------------------: | :------------------------------------------------------------------------ |
| python | [Python 3 and above](https://www.python.org/downloads/) <br/> coverage.py |

## Usage

#### First install Coverage library:

```
pip install coverage
```

For Python, Keploy will automatically generate the coverage report after you run the command below.

```
keploy test -c "your_application_command"
```

If you’re running with **Unicorn**, use the following command:

```
keploy test -c "python -m uvicorn application.main:app --reload" --delay 10
```

After successful execution of this command, A coverage report would be generated inside the test-run folder of keploy/reports.

```
keploy
├── reports
│ └── test-run-0
│ ├── coverage.yaml
│ └── test-set-0-report.yaml
└── test-set-0
├── mocks.yaml
└── tests
├── test-1.yaml
└── test-2.yaml
```

To get the coverage data for your unit tests:

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

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.

> Note: If you face any problems with running the coverage library, you can refer to the documentation.

### Combine And Get Report

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