Extending Function-Based Tests
In this section...
“Fixtures for Setup and Teardown Code” on page 33-42
“Test Logging and Verbosity” on page 33-43
“Test Suite Creation” on page 33-44
“Test Selection” on page 33-44
“Test Running” on page 33-45
“Programmatic Access of Test Diagnostics” on page 33-45
“Test Runner Customization” on page 33-46
Typically, with function-based tests, you create a test file and pass the file name to the
runtests function without explicitly creating a suite of Test objects. However, if you
create an explicit test suite, additional features are available in function-based testing.
These features include:
- Test logging and verbosity
- Test selection
- Plugins to customize the test runner
For additional functionality, consider using “Class-Based Unit Tests”.
Fixtures for Setup and Teardown Code
When writing tests, use the TestCase.applyFixture method to handle setup and
teardown code for actions such as:
- Changing the current working folder
- Adding a folder to the path
- Creating a temporary folder
- Suppressing the display of warnings
These fixtures take the place of manually coding the actions in the setupOnce,
teardownOnce, setup, and teardown functions of your function-based test.
33 Unit Testing