OpenShot Library | OpenShotAudio 0.2.2
|
Runs a set of unit tests. More...
#include <juce_UnitTest.h>
Classes | |
struct | TestResult |
Contains the results of a test. More... | |
Public Member Functions | |
virtual | ~UnitTestRunner () |
Destructor. More... | |
void | runTests (const Array< UnitTest * > &tests, int64 randomSeed=0) |
Runs a set of tests. More... | |
void | runAllTests (int64 randomSeed=0) |
Runs all the UnitTest objects that currently exist. More... | |
void | runTestsInCategory (const String &category, int64 randomSeed=0) |
Runs all the UnitTest objects within a specified category. More... | |
void | setAssertOnFailure (bool shouldAssert) noexcept |
Sets a flag to indicate whether an assertion should be triggered if a test fails. More... | |
void | setPassesAreLogged (bool shouldDisplayPasses) noexcept |
Sets a flag to indicate whether successful tests should be logged. More... | |
int | getNumResults () const noexcept |
Returns the number of TestResult objects that have been performed. More... | |
const TestResult * | getResult (int index) const noexcept |
Returns one of the TestResult objects that describes a test that has been run. More... | |
Protected Member Functions | |
virtual void | resultsUpdated () |
Called when the list of results changes. More... | |
virtual void | logMessage (const String &message) |
Logs a message about the current test progress. More... | |
virtual bool | shouldAbortTests () |
This can be overridden to let the runner know that it should abort the tests as soon as possible, e.g. More... | |
Friends | |
class | UnitTest |
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.
Definition at line 328 of file juce_UnitTest.h.
juce::UnitTestRunner::UnitTestRunner | ( | ) |
Definition at line 117 of file juce_UnitTest.cpp.
|
virtual |
Destructor.
Definition at line 118 of file juce_UnitTest.cpp.
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.
Definition at line 144 of file juce_UnitTest.cpp.
References logMessage(), juce::Random::nextInt(), resultsUpdated(), shouldAbortTests(), and juce::String::toHexString().
Referenced by runAllTests(), and runTestsInCategory().
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.
Definition at line 177 of file juce_UnitTest.cpp.
References juce::UnitTest::getAllTests(), and runTests().
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.
Definition at line 182 of file juce_UnitTest.cpp.
References juce::UnitTest::getTestsInCategory(), and runTests().
|
noexcept |
Sets a flag to indicate whether an assertion should be triggered if a test fails.
This is true by default.
Definition at line 120 of file juce_UnitTest.cpp.
|
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.
Definition at line 125 of file juce_UnitTest.cpp.
|
noexcept |
Returns the number of TestResult objects that have been performed.
Definition at line 130 of file juce_UnitTest.cpp.
|
noexcept |
Returns one of the TestResult objects that describes a test that has been run.
Definition at line 135 of file juce_UnitTest.cpp.
|
protectedvirtual |
Called when the list of results changes.
You can override this to perform some sort of behaviour when results are added.
Definition at line 140 of file juce_UnitTest.cpp.
Referenced by runTests().
|
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.
Definition at line 187 of file juce_UnitTest.cpp.
References juce::Logger::writeToLog().
Referenced by juce::UnitTest::logMessage(), and runTests().
|
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.
Definition at line 192 of file juce_UnitTest.cpp.
Referenced by runTests().
|
friend |
Definition at line 426 of file juce_UnitTest.h.