libwreport
3.29
|
Test case collecting several test methods, and self-registering with the singleton instance of TestRegistry. More...
#include <tests.h>
Public Member Functions | |
TestCase (const std::string &name) | |
void | register_tests_once () |
Idempotent wrapper for register_tests() | |
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. | |
virtual void | teardown () |
Clean up after the test case is run. | |
virtual void | method_setup (TestMethodResult &) |
Set up before the test method is run. | |
virtual void | method_teardown (TestMethodResult &) |
Clean up after the test method is run. | |
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... | |
TestMethod & | add_method (const std::string &name) |
Register a new test method, with the actual test function to be added later. | |
template<typename ... Args> | |
TestMethod & | add_method (const std::string &name, std::function< void()> test_function) |
Register a new test method. | |
template<typename ... Args> | |
TestMethod & | add_method (const std::string &name, const std::string &doc, std::function< void()> test_function) |
Register a new test method, including documentation. | |
Data Fields | |
std::string | name |
Name of the test case. | |
std::vector< TestMethod > | methods |
All registered test methods. | |
bool | tests_registered = false |
Set to true the first time register_tests_once is run. | |
Test case collecting several test methods, and self-registering with the singleton instance of TestRegistry.
|
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().
|
virtual |
Run a test method.
Call method_setup(), run all the tests that have been registered, then call method_teardown().
Exceptions thrown by the test method are caught and reported in TestMethodResult.
Exceptions in method_setup() and method_teardown() are caught and reported in TestMethodResult.
|
virtual |
Call setup(), run all the tests that have been registered, then call teardown().
Exceptions in setup() and teardown() are caught and reported in TestCaseResult. Test are run using run_test().