Runs a set of unit tests.
More...
#include <juce_UnitTest.h>
|
| virtual void | logMessage (const String &message) |
| | Logs a message about the current test progress.
|
| |
| virtual void | resultsUpdated () |
| | Called when the list of results changes.
|
| |
| 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.
- See also
- UnitTest
@tags{Core}
◆ UnitTestRunner()
| juce::UnitTestRunner::UnitTestRunner |
( |
| ) |
|
◆ ~UnitTestRunner()
| virtual juce::UnitTestRunner::~UnitTestRunner |
( |
| ) |
|
|
virtual |
◆ addFail()
| void juce::UnitTestRunner::addFail |
( |
const String & |
failureMessage | ) |
|
|
private |
◆ addPass()
| void juce::UnitTestRunner::addPass |
( |
| ) |
|
|
private |
◆ beginNewTest()
| void juce::UnitTestRunner::beginNewTest |
( |
UnitTest * |
test, |
|
|
const String & |
subCategory |
|
) |
| |
|
private |
◆ endTest()
| void juce::UnitTestRunner::endTest |
( |
| ) |
|
|
private |
◆ getNumResults()
| int juce::UnitTestRunner::getNumResults |
( |
| ) |
const |
|
noexcept |
◆ getResult()
| const TestResult * juce::UnitTestRunner::getResult |
( |
int |
index | ) |
const |
|
noexcept |
◆ logMessage()
| virtual void juce::UnitTestRunner::logMessage |
( |
const String & |
message | ) |
|
|
protectedvirtual |
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.
◆ resultsUpdated()
| virtual void juce::UnitTestRunner::resultsUpdated |
( |
| ) |
|
|
protectedvirtual |
Called when the list of results changes.
You can override this to perform some sort of behaviour when results are added.
◆ runAllTests()
| void juce::UnitTestRunner::runAllTests |
( |
int64 |
randomSeed = 0 | ) |
|
Runs all the UnitTest objects that currently exist.
This calls runTests() for all the objects listed in UnitTest::getAllTests().
If you want to run the tests with a predetermined seed, you can pass that into the randomSeed argument, or pass 0 to have a randomly-generated seed chosen.
◆ runTests()
| void juce::UnitTestRunner::runTests |
( |
const Array< UnitTest * > & |
tests, |
|
|
int64 |
randomSeed = 0 |
|
) |
| |
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().
If you want to run the tests with a predetermined seed, you can pass that into the randomSeed argument, or pass 0 to have a randomly-generated seed chosen.
◆ runTestsInCategory()
| void juce::UnitTestRunner::runTestsInCategory |
( |
const String & |
category, |
|
|
int64 |
randomSeed = 0 |
|
) |
| |
Runs all the UnitTest objects within a specified category.
This calls runTests() for all the objects listed in UnitTest::getTestsInCategory().
If you want to run the tests with a predetermined seed, you can pass that into the randomSeed argument, or pass 0 to have a randomly-generated seed chosen.
◆ runTestsWithName()
| void juce::UnitTestRunner::runTestsWithName |
( |
const String & |
name, |
|
|
int64 |
randomSeed = 0 |
|
) |
| |
Runs all the UnitTest objects with a specified name.
This calls runTests() for all the objects listed in UnitTest::getTestsWithName().
If you want to run the tests with a predetermined seed, you can pass that into the randomSeed argument, or pass 0 to have a randomly-generated seed chosen.
◆ setAssertOnFailure()
| void juce::UnitTestRunner::setAssertOnFailure |
( |
bool |
shouldAssert | ) |
|
|
noexcept |
Sets a flag to indicate whether an assertion should be triggered if a test fails.
This is true by default.
◆ setPassesAreLogged()
| void juce::UnitTestRunner::setPassesAreLogged |
( |
bool |
shouldDisplayPasses | ) |
|
|
noexcept |
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.
◆ shouldAbortTests()
| virtual bool juce::UnitTestRunner::shouldAbortTests |
( |
| ) |
|
|
protectedvirtual |
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.
◆ UnitTest
◆ assertOnFailure
| bool juce::UnitTestRunner::assertOnFailure = true |
|
private |
◆ currentSubCategory
| String juce::UnitTestRunner::currentSubCategory |
|
private |
◆ currentTest
| UnitTest* juce::UnitTestRunner::currentTest = nullptr |
|
private |
◆ logPasses
| bool juce::UnitTestRunner::logPasses = false |
|
private |
◆ randomForTest
| Random juce::UnitTestRunner::randomForTest |
|
private |
◆ results
The documentation for this class was generated from the following file: