This repository contains examples for the Audition testing framework. No example exceeds the test limit for the unregistered version of Audition which means you can try them with Audition for free (no purchase necessary).
The examples include:
- Minimal Example - One function, one test case (the “Hello, World!” of Audition).
- Looped Test - Repeat one test case multiple times.
- Test Fixtures - Define preconditions and postconditions for the runner, suite(s), and test(s).
- Table Driven Testing - Drive tests using an array of input data.
- Capture Standard Streams - Capture
stdout
and verify its contents are correct. - Simulate Standard Input - Simulate
stdin
for code that reads from it. - Catch Crashes - Tests that might crash can be executed in a separate address space.
- Catch Timeouts - Abort long running or hanging tests by using a test timeout.
- Death Testing - Check expected program termination and verify the exit status code.
- Signal Testing - Check if a specific POSIX signal was raised.
- File-driven Testing - Drive tests using files from the file system.
- Snapshot Testing - Like file-driven testing but generates expected output files at runtime.
- Static Function Testing - A strategy for testing static functions.
- Mocking with Fakes - Mock a function by redirecting calls to it to another function.
- Mocking with Stubs - Mock a function by having it always return a hard-coded return value.
- Mocking with Spies - Intercept calls to a function without altering its behavior.
- Selective Mocking - Mock system functions without affecting third-party libraries.
Use CMake to build and run the examples:
$ cmake -B build
$ cmake --build build --config Release
$ ctest --test-dir build --output-on-failure -C Release
or navigate to each test directory and compile the source files yourself (be sure to link against the Audition library).
If you're running Linux and you installed Audition with a .deb
or .rpm
, then you can use pkg-config to find the Audition library and header:
$ pkg-config audition --libs --cflags
This work is dedicated to the public domain.