matador::test_suite Class Reference

The container for all unit tests. More...

#include <test_suite.hpp>

Classes

struct  summary
 Holds the summary result of the executed tests. More...
 
struct  test_suite_args
 
struct  test_unit_args
 

Public Types

enum  test_suite_cmd { UNKNOWN = 0 , LIST , EXECUTE }
 test_suite commands More...
 
typedef std::vector< std::string > t_string_vector
 

Public Member Functions

void init (int argc, char *argv[])
 Initialize test_suite.
 
void register_unit (unit_test *utest)
 Register a new test_unit serializable.
 
bool run ()
 Executes the test_suite.
 
bool run (const std::string &unit)
 Executes a specific test_unit.
 
bool run (const test_unit_args &unit_args)
 Executes a specific test_unit.
 
bool run (const std::string &unit, const std::string &test)
 Executes a single test of a test_unit.
 
std::size_t size () const
 
bool empty () const
 
t_unit_test_map::const_iterator begin () const
 
t_unit_test_map::const_iterator end () const
 
const summarytest_summary () const
 
const test_suite_argstest_args () const
 
void quiet (bool q=true)
 

Detailed Description

The container for all unit tests.

The test_suite class is the container for all test_unit classes. It is a singleton, so only one instance exists. It can execute all test_units or a specific test_unit. It also provides function listing all test_unit classes and their tests.

Member Typedef Documentation

◆ t_string_vector

typedef std::vector<std::string> matador::test_suite::t_string_vector

Shortcut for a string vector

Member Enumeration Documentation

◆ test_suite_cmd

test_suite commands

This is an enumeration for all test_suite commands

Enumerator
UNKNOWN 

Enum type for an unknown test_suite command.

LIST 

Enum type for the list command.

EXECUTE 

Enum type for the execute command.

Member Function Documentation

◆ begin()

t_unit_test_map::const_iterator matador::test_suite::begin ( ) const

Returns the begin iterator of the unit test map

Returns
Begin iterator of the unit test map

◆ empty()

bool matador::test_suite::empty ( ) const

Returns true if test suite is empty

Returns
True if test suite is empty

◆ end()

t_unit_test_map::const_iterator matador::test_suite::end ( ) const

Returns the end iterator of the unit test map

Returns
End iterator of the unit test map

◆ init()

void matador::test_suite::init ( int  argc,
char *  argv[] 
)

Initialize test_suite.

Reads, parses and initializes the test_suite.

Parameters
argcNumber of arguments.
argvList of arguments.

◆ quiet()

void matador::test_suite::quiet ( bool  q = true)

Disables any output

Parameters
qIf true a output is disabled

◆ register_unit()

void matador::test_suite::register_unit ( unit_test utest)

Register a new test_unit serializable.

Registers a new test_unit serializable identified by the given name.

Parameters
utesttest_unit serializable.

◆ run() [1/4]

bool matador::test_suite::run ( )

Executes the test_suite.

Executes all test unit classes or the command given via init.

Returns
True if all tests succeeded.

◆ run() [2/4]

bool matador::test_suite::run ( const std::string &  unit)

Executes a specific test_unit.

Executes the test_unit with the given name. If there is no test_unit serializable with such a name a message is displayed.

Parameters
unitThe name of the test_unit serializable to execute.
Returns
True if all tests succeeded.

◆ run() [3/4]

bool matador::test_suite::run ( const std::string &  unit,
const std::string &  test 
)

Executes a single test of a test_unit.

Executes a single test of a test_unit serializable, identified by the name of the test and the name of the test_unit serializable. If test couldn't be found a message is displayed.

Parameters
unitName of the test_unit serializable.
testName of the test to execute.
Returns
True if test succeeded.

◆ run() [4/4]

bool matador::test_suite::run ( const test_unit_args unit_args)

Executes a specific test_unit.

Executes the test_unit with the given args. Arguments contain name of test unit and a list of all tests to be executed. If list is empty all tests are executed. If there is no test_unit serializable with such a name a message is displayed.

Parameters
unit_argsThe arguments of the test_unit to execute.
Returns
True if all tests succeeded.

◆ size()

std::size_t matador::test_suite::size ( ) const

Returns the number of unit test classes

Returns
Number of unit test classes

◆ test_args()

const test_suite_args & matador::test_suite::test_args ( ) const

Returns test suites configurated arguments

Returns
Test suites configurated arguments

◆ test_summary()

const summary & matador::test_suite::test_summary ( ) const

Return the current summary for the test suite

Returns
Current summary for the test suite

The documentation for this class was generated from the following file:
  • matador/unit/test_suite.hpp