diff --git a/TESTING.md b/TESTING.md new file mode 100644 index 0000000..f4c36a9 --- /dev/null +++ b/TESTING.md @@ -0,0 +1,44 @@ +# Unit Testing Guide - be-rbd + +This document provides instructions on how to set up and run unit tests for the **be-rbd** project. + +## 1. Preparation + +### Install Dependencies +Ensure you have all dependencies installed. This project uses `poetry`. + +```bash +# Install dependencies +poetry install +``` + +## 2. Configuration + +### Pytest Configuration +Ensure the `pytest.ini` file in the root directory points to the `unit` test folder: + +```ini +[pytest] +testpaths = tests/unit +python_files = test_*.py +asyncio_mode = auto +``` + +## 3. Running Tests + +### Run Unit Tests +To run all unit tests in the project: + +```bash +poetry run pytest tests/unit +``` + +### Run Specific Unit Test File +```bash +poetry run pytest tests/unit/test_specific_feature.py +``` + +## 4. Best Practices + +- **Isolation**: Unit tests should be isolated from external services. Use mocking for APIs and databases. +- **Async Testing**: Use `@pytest.mark.asyncio` for asynchronous test functions. diff --git a/pytest.ini b/pytest.ini index 3259ad7..d3f7b54 100644 --- a/pytest.ini +++ b/pytest.ini @@ -1,6 +1,6 @@ [pytest] asyncio_mode = auto -testpaths = tests +testpaths = tests/unit python_files = test_*.py filterwarnings = ignore::pydantic.PydanticDeprecatedSince20