seitime-frappe/frappe/testing/README.md
David Arnold 7e453ea515
Testing Module (#28000)
* refactor: add create_handler alongside create_logger

* fix: bench helper click exceptions for --help (2nd attempt)

* fix: increase logging level missing test records

* fix: reorganize test runner into testing module and refine logging

* fix: semgrep complaint

* chore: remove unused code; only keep deprecation proxies

* fix: import statements

* fix: output & string processing
2024-10-07 09:46:49 +02:00

37 lines
1.7 KiB
Markdown

# Frappe Testing Module
This module provides a comprehensive framework for running tests in Frappe applications. It includes functionality for test discovery, execution, result reporting, and environment setup.
## Key Components
- `TestConfig`: Configuration class for customizing test execution
- `TestRunner`: Main class for running test suites with additional Frappe-specific functionality
- `TestResult`: Custom test result class for improved output formatting and logging
- `discover_all_tests`: Function to discover all tests in specified Frappe apps
- `discover_doctype_tests`: Function to discover tests for specific DocTypes
- `discover_module_tests`: Function to discover tests in specific modules
## Usage
This module is typically used by Frappe's CLI commands for running tests, but can also be used programmatically for custom test execution scenarios.
For detailed information about each component, please refer to the well-commented code in the following files:
- [`__init__.py`](./__init__.py): Module initialization and logging setup
- [`runner.py`](./runner.py): TestRunner class and test execution logic
- [`discovery.py`](./discovery.py): Test discovery functions
- [`result.py`](./result.py): Custom TestResult class for result handling
- [`environment.py`](./environment.py): Test environment setup and teardown
## Example
```python
from frappe.testing import TestConfig, TestRunner, discover_all_tests
config = TestConfig(failfast=True, verbose=2)
runner = TestRunner(cfg=config)
discover_all_tests(['my_app'], runner)
runner.run()
```
For more detailed information about each component and its functionality, please refer to the docstrings and comments in the respective files.