OpenShot Audio Library | OpenShotAudio 0.3.2
Loading...
Searching...
No Matches
juce::UnitTestRunner Class Reference

#include <juce_UnitTest.h>

Classes

struct  TestResult
 

Public Member Functions

virtual ~UnitTestRunner ()
 
void runTests (const Array< UnitTest * > &tests, int64 randomSeed=0)
 
void runAllTests (int64 randomSeed=0)
 
void runTestsInCategory (const String &category, int64 randomSeed=0)
 
void setAssertOnFailure (bool shouldAssert) noexcept
 
void setPassesAreLogged (bool shouldDisplayPasses) noexcept
 
int getNumResults () const noexcept
 
const TestResultgetResult (int index) const noexcept
 

Protected Member Functions

virtual void resultsUpdated ()
 
virtual void logMessage (const String &message)
 
virtual bool shouldAbortTests ()
 

Detailed Description

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

Definition at line 324 of file juce_UnitTest.h.


Class Documentation

◆ juce::UnitTestRunner::TestResult

struct juce::UnitTestRunner::TestResult

Contains the results of a test.

One of these objects is instantiated each time UnitTest::beginTest() is called, and it contains details of the number of subsequent UnitTest::expect() calls that are made.

Definition at line 377 of file juce_UnitTest.h.

Class Members
int failures

The number of UnitTest::expect() calls that failed.

StringArray messages

A list of messages describing the failed tests.

int passes

The number of UnitTest::expect() calls that succeeded.

String subcategoryName

The name of the current subcategory (i.e. the name that was set when UnitTest::beginTest() was called).

String unitTestName

The main name of this test (i.e. the name of the UnitTest object being run).

Constructor & Destructor Documentation

◆ UnitTestRunner()

juce::UnitTestRunner::UnitTestRunner ( )

Definition at line 117 of file juce_UnitTest.cpp.

◆ ~UnitTestRunner()

juce::UnitTestRunner::~UnitTestRunner ( )
virtual

Destructor.

Definition at line 118 of file juce_UnitTest.cpp.

Member Function Documentation

◆ getNumResults()

int juce::UnitTestRunner::getNumResults ( ) const
noexcept

Returns the number of TestResult objects that have been performed.

See also
getResult

Definition at line 130 of file juce_UnitTest.cpp.

◆ getResult()

const UnitTestRunner::TestResult * juce::UnitTestRunner::getResult ( int  index) const
noexcept

Returns one of the TestResult objects that describes a test that has been run.

See also
getNumResults

Definition at line 135 of file juce_UnitTest.cpp.

◆ logMessage()

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.

Definition at line 187 of file juce_UnitTest.cpp.

Referenced by juce::UnitTest::logMessage(), and runTests().

◆ resultsUpdated()

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.

Definition at line 140 of file juce_UnitTest.cpp.

Referenced by runTests().

◆ 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.

Definition at line 177 of file juce_UnitTest.cpp.

◆ 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.

Definition at line 144 of file juce_UnitTest.cpp.

Referenced by runAllTests(), and runTestsInCategory().

◆ 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.

Definition at line 182 of file juce_UnitTest.cpp.

◆ 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.

Definition at line 120 of file juce_UnitTest.cpp.

◆ 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.

Definition at line 125 of file juce_UnitTest.cpp.

◆ shouldAbortTests()

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.

Definition at line 192 of file juce_UnitTest.cpp.

Referenced by runTests().


The documentation for this class was generated from the following files: