scsl 1.0.1
Shimmering Clarity Standard Library
|
SimpleSuite is a test-running harness for simple tests. More...
#include <SimpleSuite.h>
Public Member Functions | |
SimpleSuite () | |
void | Silence () |
Silence suppresses output. | |
void | Setup (std::function< bool(void)> setupFn) |
Define a suite setup function. | |
void | Teardown (std::function< bool(void)> teardownFn) |
Define a teardown function. | |
void | AddTest (std::string label, std::function< bool(void)> test) |
Register a new simple test. | |
void | AddFailingTest (std::string label, std::function< bool(void)> test) |
Register a test that is expected to return false. | |
bool | Run () |
Run all the registered tests. | |
void | Reset () |
Reporting methods. | |
bool | HasRun () const |
Returns true if Run has been called. | |
Report | GetReport () |
Retrieve the test run results. | |
SimpleSuite is a test-running harness for simple tests.
A simple test is defined as a test that takes no arguments and returns a boolean status where true indicates the test has passed.
sctest::SimpleSuite::SimpleSuite | ( | ) |
void sctest::SimpleSuite::AddFailingTest | ( | std::string | label, |
std::function< bool(void)> | test | ||
) |
Register a test that is expected to return false.
label | The text that will identify test when running. |
test | This test should return false if the test has passed. |
void sctest::SimpleSuite::AddTest | ( | std::string | label, |
std::function< bool(void)> | test | ||
) |
Register a new simple test.
label | The text that will identify test when running. |
test | This test should return true if the test has passed. |
Report sctest::SimpleSuite::GetReport | ( | ) |
Retrieve the test run results.
The results will only be valid if Run has been called.
bool sctest::SimpleSuite::HasRun | ( | ) | const |
Returns true if Run has been called.
void sctest::SimpleSuite::Reset | ( | ) |
Reporting methods.
Reset clears the report statistics.
Reset will preserve the setup and teardown functions, just resetting the suite's internal state.
bool sctest::SimpleSuite::Run | ( | ) |
Run all the registered tests.
|
inline |
Define a suite setup function.
If present, this setup function is called At the start of the Run method, before tests are run. It should be a predicate: if it returns false, tests automatically fail.
void sctest::SimpleSuite::Silence | ( | ) |
Silence suppresses output.
|
inline |
Define a teardown function.
If present, this teardown function is called At the end of the Run method, after all tests have run.