diff --git a/README.md b/README.md index 835cc978..534d8021 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ If you find this helpful, please consider [sponsorship](https://github.com/spons - Manage dependencies and virtual environments with [pdm](https://pdm-project.org/). - Build with [setuptools](https://github.com/pypa/setuptools) and versioned with [setuptools-scm](https://github.com/pypa/setuptools_scm/). - Lint with [pre-commit](https://pre-commit.com), [mypy](http://www.mypy-lang.org/), [ruff](https://github.com/charliermarsh/ruff), [toml-sort](https://github.com/pappasam/toml-sort) and [commitlint](https://commitlint.js.org/). -- Test with [pytest](https://pytest.org/) and [coverage](https://coverage.readthedocs.io) for threshold and reports. +- Test with [pytest](https://docs.pytest.org/) and [coverage](https://coverage.readthedocs.io) for threshold and reports. - Documentation with [sphinx](https://www.sphinx-doc.org/), the [furo](https://pradyunsg.me/furo) theme and [MyST parser](https://myst-parser.readthedocs.io/) for markdown. - Develop Command Line Interfaces with [typer](https://typer.tiangolo.com/). - Manage configurations with [pydantic-settings](https://docs.pydantic.dev/latest/usage/pydantic_settings/). diff --git a/docs/development/index.md b/docs/development/index.md index 03fc20fb..24ff799a 100644 --- a/docs/development/index.md +++ b/docs/development/index.md @@ -7,4 +7,5 @@ git-workflow setup-dev-env cleanup-dev-env commit +tests ``` diff --git a/docs/development/tests.md b/docs/development/tests.md new file mode 100644 index 00000000..3f98ff91 --- /dev/null +++ b/docs/development/tests.md @@ -0,0 +1,27 @@ +# Tests + +In the context of CI/CD automation, dependency updates, and the release process, tests play a crucial role in daily development. We utilize [pytest](https://docs.pytest.org/) and [coverage](https://coverage.readthedocs.io) with proper configuration to ensure everything works as expected. This page provides general information and conventions we wish you to follow. + +## Running Tests + +After [setting up the development environment](/development/setup-dev-env.md), tests can be run with the command: + +```bash +make test +``` + +With the default configuration, this command displays the result for each test case, the execution time for slow test cases, and a report on test coverage. + +## Writing Tests + +For guidelines on how to write tests, refer to [the official documentation](https://docs.pytest.org/how-to/assert.html). Here are some conventions we expect you to follow: + +1. Organize all test cases under the `tests` directory. +2. Align test modules with the modules to be tested. + + For example, tests for the `ss_python.cli` module should be located in the file `tests/cli_test.py`. If there are too many test cases, they can be split into files within the `tests/cli/` directory, using a prefix for each test file. +3. Unless necessary, do not lower the threshold of the test coverage. + +## Coverage Report + +After running the tests, the coverage report will be printed on the screen and generated as part of the documentation. You can view it [here](/reports/coverage/index.md). diff --git a/includes/sample.jinja b/includes/sample.jinja index ebdc7b4d..b75c623c 100644 --- a/includes/sample.jinja +++ b/includes/sample.jinja @@ -16,7 +16,7 @@ If you find this helpful, please consider [sponsorship](https://github.com/spons - Manage dependencies and virtual environments with [pdm](https://pdm-project.org/). - Build with [setuptools](https://github.com/pypa/setuptools) and versioned with [setuptools-scm](https://github.com/pypa/setuptools_scm/). - Lint with [pre-commit](https://pre-commit.com), [mypy](http://www.mypy-lang.org/), [ruff](https://github.com/charliermarsh/ruff), [toml-sort](https://github.com/pappasam/toml-sort) and [commitlint](https://commitlint.js.org/). -- Test with [pytest](https://pytest.org/) and [coverage](https://coverage.readthedocs.io) for threshold and reports. +- Test with [pytest](https://docs.pytest.org/) and [coverage](https://coverage.readthedocs.io) for threshold and reports. - Documentation with [sphinx](https://www.sphinx-doc.org/), the [furo](https://pradyunsg.me/furo) theme and [MyST parser](https://myst-parser.readthedocs.io/) for markdown. - Develop Command Line Interfaces with [typer](https://typer.tiangolo.com/). - Manage configurations with [pydantic-settings](https://docs.pydantic.dev/latest/usage/pydantic_settings/). diff --git a/template/docs/development/index.md b/template/docs/development/index.md index 03fc20fb..24ff799a 100644 --- a/template/docs/development/index.md +++ b/template/docs/development/index.md @@ -7,4 +7,5 @@ git-workflow setup-dev-env cleanup-dev-env commit +tests ``` diff --git a/template/docs/development/tests.md.jinja b/template/docs/development/tests.md.jinja new file mode 100644 index 00000000..ea2063fc --- /dev/null +++ b/template/docs/development/tests.md.jinja @@ -0,0 +1,27 @@ +# Tests + +In the context of CI/CD automation, dependency updates, and the release process, tests play a crucial role in daily development. We utilize [pytest](https://docs.pytest.org/) and [coverage](https://coverage.readthedocs.io) with proper configuration to ensure everything works as expected. This page provides general information and conventions we wish you to follow. + +## Running Tests + +After [setting up the development environment](/development/setup-dev-env.md), tests can be run with the command: + +```bash +make test +``` + +With the default configuration, this command displays the result for each test case, the execution time for slow test cases, and a report on test coverage. + +## Writing Tests + +For guidelines on how to write tests, refer to [the official documentation](https://docs.pytest.org/how-to/assert.html). Here are some conventions we expect you to follow: + +1. Organize all test cases under the `tests` directory. +2. Align test modules with the modules to be tested. + + For example, tests for the `{{ module_name}}.cli` module should be located in the file `tests/cli_test.py`. If there are too many test cases, they can be split into files within the `tests/cli/` directory, using a prefix for each test file. +3. Unless necessary, do not lower the threshold of the test coverage. + +## Coverage Report + +After running the tests, the coverage report will be printed on the screen and generated as part of the documentation. You can view it [here](/reports/coverage/index.md).