libept
Public Member Functions | Public Attributes | List of all members
ept::tests::TestCase Struct Referenceabstract

Test case collecting several test methods, and self-registering with the singleton instance of TestRegistry. More...

#include <tests.h>

Inheritance diagram for ept::tests::TestCase:
ept::tests::FixtureTestCase< FIXTURE >

Public Member Functions

 TestCase (const std::string &name)
 
virtual ~TestCase ()
 
virtual void register_tests ()=0
 This will be called before running the test case, to populate it with its test methods. More...
 
virtual void setup ()
 Set up the test case before it is run. More...
 
virtual void teardown ()
 Clean up after the test case is run. More...
 
virtual void method_setup (TestMethodResult &)
 Set up before the test method is run. More...
 
virtual void method_teardown (TestMethodResult &)
 Clean up after the test method is run. More...
 
virtual TestCaseResult run_tests (TestController &controller)
 Call setup(), run all the tests that have been registered, then call teardown(). More...
 
virtual TestMethodResult run_test (TestController &controller, TestMethod &method)
 Run a test method. More...
 
template<typename ... Args>
void add_method (const std::string &name, std::function< void()> test_function)
 Register a new test method. More...
 
template<typename ... Args>
void add_method (const std::string &name, std::function< void()> test_function, Args &&... args)
 Register a new test method. More...
 
template<typename FUNC , typename ... Args>
void add_method (const std::string &name, FUNC test_function, Args &&... args)
 Register a new test metheod, with arguments. More...
 

Public Attributes

std::string name
 Name of the test case. More...
 
std::vector< TestMethodmethods
 All registered test methods. More...
 

Detailed Description

Test case collecting several test methods, and self-registering with the singleton instance of TestRegistry.

Constructor & Destructor Documentation

◆ TestCase()

ept::tests::TestCase::TestCase ( const std::string &  name)
inline

◆ ~TestCase()

virtual ept::tests::TestCase::~TestCase ( )
inlinevirtual

References register_tests().

Member Function Documentation

◆ add_method() [1/3]

template<typename ... Args>
void ept::tests::TestCase::add_method ( const std::string &  name,
std::function< void()>  test_function 
)
inline

Register a new test method.

◆ add_method() [2/3]

template<typename ... Args>
void ept::tests::TestCase::add_method ( const std::string &  name,
std::function< void()>  test_function,
Args &&...  args 
)
inline

Register a new test method.

◆ add_method() [3/3]

template<typename FUNC , typename ... Args>
void ept::tests::TestCase::add_method ( const std::string &  name,
FUNC  test_function,
Args &&...  args 
)
inline

Register a new test metheod, with arguments.

Any extra arguments to the function will be passed to the test method.

◆ method_setup()

virtual void ept::tests::TestCase::method_setup ( TestMethodResult )
inlinevirtual

Set up before the test method is run.

Reimplemented in ept::tests::FixtureTestCase< FIXTURE >.

Referenced by ept::tests::FixtureTestCase< FIXTURE >::method_setup().

◆ method_teardown()

virtual void ept::tests::TestCase::method_teardown ( TestMethodResult )
inlinevirtual

Clean up after the test method is run.

Reimplemented in ept::tests::FixtureTestCase< FIXTURE >.

Referenced by ept::tests::FixtureTestCase< FIXTURE >::method_teardown().

◆ register_tests()

virtual void ept::tests::TestCase::register_tests ( )
pure virtual

This will be called before running the test case, to populate it with its test methods.

This needs to be reimplemented with a function that will mostly be a sequence of calls to add_method().

◆ run_test()

TestMethodResult ept::tests::TestCase::run_test ( TestController controller,
TestMethod method 
)
virtual

◆ run_tests()

TestCaseResult ept::tests::TestCase::run_tests ( TestController controller)
virtual

◆ setup()

virtual void ept::tests::TestCase::setup ( )
inlinevirtual

Set up the test case before it is run.

Reimplemented in ept::tests::FixtureTestCase< FIXTURE >.

Referenced by ept::tests::FixtureTestCase< FIXTURE >::setup().

◆ teardown()

virtual void ept::tests::TestCase::teardown ( )
inlinevirtual

Clean up after the test case is run.

Reimplemented in ept::tests::FixtureTestCase< FIXTURE >.

Referenced by ept::tests::FixtureTestCase< FIXTURE >::teardown().

Member Data Documentation

◆ methods

std::vector<TestMethod> ept::tests::TestCase::methods

All registered test methods.

Referenced by ept::tests::SimpleTestController::test_case_begin().

◆ name

std::string ept::tests::TestCase::name

Name of the test case.

Referenced by ept::tests::SimpleTestController::test_case_begin().


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