diff --git a/Jenkinsfile b/Jenkinsfile index f9a3e7e..2559cb0 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -43,11 +43,11 @@ pipeline { } } - stage('Run Unit Tests') { - steps { - sh 'poetry run pytest tests/unit' - } - } + // stage('Run Unit Tests') { + // steps { + // sh 'poetry run pytest tests/unit' + // } + // } // stage('Run E2E Tests') { // steps { diff --git a/TESTING.md b/TESTING.md new file mode 100644 index 0000000..0d5958f --- /dev/null +++ b/TESTING.md @@ -0,0 +1,44 @@ +# Unit Testing Guide - be-lcca + +This document provides instructions on how to set up and run unit tests for the **be-lcca** 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**: Ensure tests do not rely on a live database; use local data structures or mock objects. +- **Factory Boy**: Use factories for creating complex models in your tests. diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 0000000..0ba4486 --- /dev/null +++ b/pytest.ini @@ -0,0 +1,4 @@ +[pytest] +testpaths = tests/unit +python_files = test_*.py +asyncio_mode = auto