Skip to content

Commit

Permalink
test: add code coverage (#133)
Browse files Browse the repository at this point in the history
  • Loading branch information
jayachithra authored Oct 4, 2024
1 parent 3462ff1 commit b5349b0
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
"extensions": [
"GitHub.copilot",
"ms-python.python",
"ms-dotnettools.csharp"
"ms-dotnettools.csharp",
"ryanluker.vscode-coverage-gutters"
]
}
}
Expand Down
24 changes: 24 additions & 0 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,30 @@ To run linting, run the following command:
poetry run ruff .
```

### Run tests

We use pytest to test our code, coverage.py to generate coverage reports and [coverage gutters](https://marketplace.visualstudio.com/items?itemName=semasquare.vscode-coverage-gutters#:~:text=Features.%20Supports%20any%20language%20as%20long%20as%20you) VSCode extension to visualize code coverage in the editor.

To run all tests and generate coverage data run the following command:

```bash
poetry run coverage run --source=src -m pytest .
```

This will generate a .coverage file. To visualize code coverage, generate a coverage.xml file from the .coverage file by running:

```bash
poetry run coverage xml
```

Once the xml file is generated, you can view the coverage results in the editor by running the `Coverage Gutters: Watch` command.

To run tests and generate coverage.xml in a single command, run:

```bash
poetry run coverage run --source=src -m pytest . && coverage xml
```

### Updating lock file

When updating Poetry's lock file your local cache can become outdated.
Expand Down

0 comments on commit b5349b0

Please sign in to comment.