TestRunner
Test runner for executing registered test cases.
The TestRunner coordinates test execution: 1. Creates test run folder for output 2. Sets up TestContext with utilities 3. Runs test setup, run, verify, teardown phases 4. Collects results and generates reports
Classes
- class TestSuiteResult
Result of running a test suite.
Methods:
- passed()
True if all tests passed.
- passed_count()
Number of tests that passed.
- failed_count()
Number of tests that failed.
- total_count()
Total number of tests.
- class TestRunner
Executes registered test cases and collects results.
- Usage:
runner = TestRunner()
# List available tests for info in runner.list_tests():
print(f”{info.name}: {info.description}”)
# Run a single test result = runner.run_test(“algorithm_watershed”)
# Run all tests in a category suite_result = runner.run_suite(“algorithms”)
# Run all tests suite_result = runner.run_suite(“all”)
Methods:
- __init__()
Initialize test runner.
- list_tests()
List available test cases.
- list_categories()
List available test categories.
- run_test()
Run a single test case by name.
- run_suite()
Run a suite of tests.
- discover_tests()
Discover and register test cases from TestCases package.
Functions
- passed()
True if all tests passed.
- passed_count()
Number of tests that passed.
- failed_count()
Number of tests that failed.
- total_count()
Total number of tests.
- list_tests()
List available test cases.
- Args:
category: Optional category filter.
- Returns:
List of TestCaseInfo objects.
- list_categories()
List available test categories.
- Returns:
List of category names.
- run_test()
Run a single test case by name.
- Args:
name: Name of test to run. test_run_folder: Optional existing test run folder.
- Returns:
TestResult with pass/fail status and details.
- Raises:
ValueError: If test name not found.
- run_suite()
Run a suite of tests.
- Args:
- suite: Suite name. Can be “all” or a category name
(e.g., “algorithm”, “ui”, “workflow”).
- Returns:
TestSuiteResult with all test results.
- discover_tests()
Discover and register test cases from TestCases package.
This imports all test modules to trigger @register_test decorators.