UTPP
Loading...
Searching...
No Matches
Execution Control

Macros

#define TEST_MAIN(ARGC, ARGV)
 

Functions

int UnitTest::RunAllTests (Reporter &rpt=GetDefaultReporter(), int max_time_ms=0)
 Run all tests from all test suites.
 
int UnitTest::RunSuite (const char *suite_name, Reporter &rpt=GetDefaultReporter(), int max_time_ms=0)
 Run all tests from one suite.
 
void UnitTest::DisableSuite (const std::string &suite_name)
 Disable a test suite.
 
void UnitTest::EnableSuite (const std::string &suite_name)
 Enable a test suite.
 

Detailed Description

Macro Definition Documentation

◆ TEST_MAIN

#define TEST_MAIN ( ARGC,
ARGV )

Replacement macro for main function.

This macro is used instead of int main(int argc, char** argv) function if you are compiling under C++11 or C++14 language rules. If you are compiling under C++17 or newer language rules, you can use the normal main function.

Note
This macro is the price to pay for having a header only library. UTPP needs a few global variables and C++14 does not allow inline static variables.

Function Documentation

◆ DisableSuite()

void UnitTest::DisableSuite ( const std::string & suite_name)
inline

Disable a test suite.

By default, the UnitTest::RunAllTests() function runs all test suites. You can disable a specific suite using this function.

Parameters
suite_namename of suite to disable

◆ EnableSuite()

void UnitTest::EnableSuite ( const std::string & suite_name)
inline

Enable a test suite.

Re-enables a test suite that has been previously disabled.

Parameters
suite_namename of suite to enable

◆ RunAllTests()

int UnitTest::RunAllTests ( Reporter & rpt,
int max_time_ms )
inline

Run all tests from all test suites.

Runs all test suites and produces results using the given reporter.

Parameters
rptReporter used to generate results
max_time_msGlobal time constraint or 0 if there is no time constraint.
Returns
number of failed tests

Each test is expected to run in under max_time_ms milliseconds. If a test takes longer, it generates a time constraint failure.

All previous statistics of the reporter object are erased.

◆ RunSuite()

int UnitTest::RunSuite ( const char * suite_name,
Reporter & rpt,
int max_time_ms )
inline

Run all tests from one suite.

Runs all tests from one suite

Parameters
suite_nameName of the suite to run
rptTest reporter to be used for results
max_time_msGlobal time constraint in milliseconds
Returns
number of tests that failed or -1 if there is no such suite