Runs a set of unit tests. More...
Classes | |
| struct | TestResult |
| Contains the results of a test. More... | |
Public Member Functions | |
| UnitTestRunner () | |
| virtual | ~UnitTestRunner () |
| Destructor. | |
| void | runTests (const Array< UnitTest * > &tests) |
| Runs a set of tests. | |
| void | runAllTests () |
| Runs all the UnitTest objects that currently exist. | |
| void | setAssertOnFailure (bool shouldAssert) noexcept |
| Sets a flag to indicate whether an assertion should be triggered if a test fails. | |
| void | setPassesAreLogged (bool shouldDisplayPasses) noexcept |
| Sets a flag to indicate whether successful tests should be logged. | |
| int | getNumResults () const noexcept |
| Returns the number of TestResult objects that have been performed. | |
| const TestResult * | getResult (int index) const noexcept |
| Returns one of the TestResult objects that describes a test that has been run. | |
Protected Member Functions | |
| virtual void | resultsUpdated () |
| Called when the list of results changes. | |
| virtual void | logMessage (const String &message) |
| Logs a message about the current test progress. | |
| virtual bool | shouldAbortTests () |
| This can be overridden to let the runner know that it should abort the tests as soon as possible, e.g. | |
Runs a set of unit tests.
You can instantiate one of these objects and use it to invoke tests on a set of UnitTest objects.
By using a subclass of UnitTestRunner, you can intercept logging messages and perform custom behaviour when each test completes.
| virtual UnitTestRunner::~UnitTestRunner | ( | ) | [virtual] |
Destructor.
| void UnitTestRunner::runTests | ( | const Array< UnitTest * > & | tests | ) |
Runs a set of tests.
The tests are performed in order, and the results are logged. To run all the registered UnitTest objects that exist, use runAllTests().
| void UnitTestRunner::runAllTests | ( | ) |
Runs all the UnitTest objects that currently exist.
This calls runTests() for all the objects listed in UnitTest::getAllTests().
| void UnitTestRunner::setAssertOnFailure | ( | bool | shouldAssert | ) |
Sets a flag to indicate whether an assertion should be triggered if a test fails.
This is true by default.
| void UnitTestRunner::setPassesAreLogged | ( | bool | shouldDisplayPasses | ) |
Sets a flag to indicate whether successful tests should be logged.
By default, this is set to false, so that only failures will be displayed in the log.
| int UnitTestRunner::getNumResults | ( | ) | const |
Returns the number of TestResult objects that have been performed.
| const TestResult* UnitTestRunner::getResult | ( | int | index | ) | const |
Returns one of the TestResult objects that describes a test that has been run.
| virtual void UnitTestRunner::resultsUpdated | ( | ) | [protected, virtual] |
Called when the list of results changes.
You can override this to perform some sort of behaviour when results are added.
| virtual void UnitTestRunner::logMessage | ( | const String & | message | ) | [protected, virtual] |
Logs a message about the current test progress.
By default this just writes the message to the Logger class, but you could override this to do something else with the data.
| virtual bool UnitTestRunner::shouldAbortTests | ( | ) | [protected, virtual] |
This can be overridden to let the runner know that it should abort the tests as soon as possible, e.g.
because the thread needs to stop.