You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

951 B

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.

# Install dependencies
poetry install

2. Configuration

Pytest Configuration

Ensure the pytest.ini file in the root directory points to the unit test folder:

[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:

poetry run pytest tests/unit

Run Specific Unit Test File

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.