-
-
Notifications
You must be signed in to change notification settings - Fork 2
Developer Documentation
FOAMFlask includes a comprehensive test suite using pytest. The test suite includes unit tests, integration tests, and end-to-end tests for the application's core functionality.
-
Install test dependencies (if not already installed):
uv sync
-
Run all tests with coverage:
# Run all tests with coverage uv run pytest --cov=app --cov=backend --cov-report=term-missing --cov-report=html -
Run specific test files or individual tests:
# Run a specific test file uv run pytest test/test_app.py -v # Run a specific test function uv run pytest test/test_app.py::test_index_route -v
-
Run tests in parallel (faster execution):
uv run pytest -n auto --cov=app --cov=backend
To check test coverage and generate reports:
# Generate HTML coverage report (recommended)
uv run pytest --cov=app --cov=backend --cov-report=html
# View coverage in terminal
uv run pytest --cov=app --cov=backend --cov-report=term-missing
# Generate XML report (for CI/CD integration)
uv run pytest --cov=app --cov=backend --cov-report=xmlCoverage Reports:
- HTML report will be generated in the
htmlcovdirectory - Open
htmlcov/index.htmlin your browser to view the detailed coverage report - The terminal report shows which lines are missing coverage
test/
├── conftest.py # Test fixtures and configuration
├── test_app.py # Main application tests
└── test_security.py # Security-related tests
- Create a new test file following the naming convention
test_*.py - Use pytest fixtures from
conftest.pywhen available - Follow the existing test patterns for consistency
- Include docstrings explaining what each test verifies
# Run all tests with coverage
uv run pytest --cov=app --cov=backend
# Run tests without coverage
uv run pytest
# Run tests with detailed output
uv run pytest -v
# Run tests and stop after first failure
uv run pytest -x
# Run tests and show output from print statements
uv run pytest -s
# Run tests matching a specific pattern
uv run pytest -k "test_name_pattern"For users who want to contribute or fork the project.
Project Architecture: Explain the folder structure (Flask backend, static/ HTML/JS frontend).
API Endpoints: A brief overview of the Flask routes that serve the plot data and execute commands.
Generating Docs: The pdoc commands currently at the bottom of your wiki for generating Python HTML/Markdown documentation.
Building/Extending: How to add new OpenFOAM command buttons or new plot types.