A suite of tests to run. More...
#include <test.h>
Public Types | |
enum | TestType { BVT = 1, UNIT, SYSTEM, EXAMPLE, PERFORMANCE } |
Type of test. More... | |
Public Member Functions | |
TestSuite (std::string name, TestType type=UNIT) | |
Constuct a new test suite. | |
virtual | ~TestSuite () |
Destroy a test suite. | |
bool | Run (void) |
Run this test suite. | |
uint32_t | AddTestCase (TestCase *testCase) |
Add an individual test case to this test suite. | |
uint32_t | GetNTestCases (void) |
Get the number of test cases that have been added to this test suite. | |
TestCase * | GetTestCase (uint32_t i) |
Get the test case at index i. | |
TestType | GetTestType (void) |
get the kind of test this test suite implements | |
void | SetVerbose (bool verbose) |
Set the verbosity of this test suite. | |
void | SetContinueOnFailure (bool continueOnFailure) |
Tell the test suite and its test cases whether or not to continue testing if an error is detected. | |
void | SetName (std::string name) |
Set the name of this test suite. | |
std::string | GetName (void) |
Get the name of this test suite. | |
void | SetBaseDir (std::string basedir) |
Set the base directory of the ns-3 distribution. | |
std::string | GetBaseDir (void) |
Get the base directory of the ns-3 distribution. | |
void | SetTempDir (std::string dir) |
Set the temporary file directory (where to write temporary files). | |
std::string | GetTempDir (void) |
Get the temporary file directory. | |
void | SetStream (std::ofstream *ofs) |
Set the stream to which status and result messages will be written. | |
void | UpdateErrorStatus (bool error) |
Manually update the error status of this test suite. | |
void | SetErrorStatus (bool error) |
Manually set the error status of this test suite. | |
bool | GetErrorStatus (void) |
Get the error status of this test suite. | |
bool | ContinueOnFailure (void) |
Should test suite continue running cases in the presence of errors? | |
void | ReportStart (void) |
Issue a test report than the test suite has started running. | |
void | ReportSuccess (void) |
Issue a test report than the test suite has declared success. | |
void | ReportFailure (void) |
Issue a test report than the test suite has found an error. | |
void | ReportEnd (void) |
Issue a test report than the test suite has completed its run. | |
Protected Member Functions | |
virtual void | DoReportStart (void) |
virtual void | DoReportSuccess (void) |
virtual void | DoReportFailure (void) |
virtual void | DoReportEnd (void) |
virtual void | DoSetup (void) |
virtual bool | DoRun (void) |
virtual void | DoTeardown (void) |
A suite of tests to run.
ns3::TestSuite::TestSuite | ( | std::string | name, | |
TestType | type = UNIT | |||
) |
Constuct a new test suite.
name | The name of the test suite. | |
type | The TestType of the test suite (defaults to UNIT test). |
uint32_t ns3::TestSuite::AddTestCase | ( | TestCase * | testCase | ) |
Add an individual test case to this test suite.
testCase | Pointer to the test case object to be added. |
bool ns3::TestSuite::ContinueOnFailure | ( | void | ) |
Should test suite continue running cases in the presence of errors?
uint32_t ns3::TestSuite::GetNTestCases | ( | void | ) |
Get the number of test cases that have been added to this test suite.
TestType ns3::TestSuite::GetTestType | ( | void | ) |
get the kind of test this test suite implements
bool ns3::TestSuite::Run | ( | void | ) |
Run this test suite.
void ns3::TestSuite::SetContinueOnFailure | ( | bool | continueOnFailure | ) |
Tell the test suite and its test cases whether or not to continue testing if an error is detected.
Typically, test suites depend on some number of test cases, which in turn depend on some number of individual tests. Often, these tests build on functionality that has been previously verified. In this case, subsequent test failures may simply be alternate manifestations of previously detected errors. Some developers may only be interested in seeing the first failure. Other developers may want to see all the information they can get, and want to see all failures. This is a matter of individual preference, so we allow this behavior to be configured.
continueOnFailure | If true, continue running test cases after a failure has been detected, otherwise stop on the first error. |
void ns3::TestSuite::SetErrorStatus | ( | bool | error | ) |
Manually set the error status of this test suite.
This sets the current error status to the argument provided. Can be used to reset any previous errors if the argument is false.
error | The status to use to set the test suite error status |
void ns3::TestSuite::SetStream | ( | std::ofstream * | ofs | ) |
Set the stream to which status and result messages will be written.
We really don't want to have to pass an ofstream around to every function and we especially don't want to have to make our clients plumb an ofstream around so we need to save it. Since file streams are not designed to be copied or assigned (what does it mean to have duplicate streams to a file) we have to stash a pointer to the stream.
ofs | output file stream |
void ns3::TestSuite::SetVerbose | ( | bool | verbose | ) |
Set the verbosity of this test suite.
verbose | Whether or not to print "stuff." |
void ns3::TestSuite::UpdateErrorStatus | ( | bool | error | ) |
Manually update the error status of this test suite.
This does a logical OR of the error argument with the current error status. If the argument is false, it does nothing. If the argument is true, it sets the error status to "an error has occurred."
error | The status to use to update the test suite error status |