The base class to implememnt a test case.
More...
#include <robottestingframework/TestCase.h>
|
| TestCase (std::string name, std::string param="") |
| TestCase constructor.
|
|
virtual | ~TestCase () |
| TestCase destructor.
|
|
virtual bool | setup (int argc, char **argv) |
| setup is called before the test run.
|
|
virtual void | tearDown () |
| tearDown is called after the test run
|
|
virtual void | run ()=0 |
| run is called by the TestCase class if setup is successfull;
|
|
void | interrupt () override |
| interrupt interrupts the current test run
|
|
void | run (TestResult &rsl) override |
| the main caller of a TestCase inherited from Test Class.
|
|
bool | succeeded () const override |
| succeeded
|
|
void | failed () |
| failed Sets the test successful flag to false which indicates that the test was not successful.
|
|
TestResult * | getResult () |
| getResult Returns an instance of TestResult if run(TestResult &result) has been already called by a TestRunner
|
|
void | setParam (const std::string param) |
| setParam Sets the optional parameters of the test.
|
|
std::string | getParam () |
| getParam gets the original paramter string which is set for the test case
|
|
void | setEnvironment (const std::string environment) |
| setEnvironment Optioanlly specifies the environment in which the test case is executed.
|
|
std::string | getEnvironment () |
| getParam gets the environment string which is set for the test case
|
|
void | setRepetition (unsigned int rep) |
| setRepetition sets the run repetition by default the run() method is called only once; The number of test runs (e.g., for stress testing) can be set using this function.
|
|
unsigned int | getRepetition () |
| getRepetition gets the tun repetition
|
|
| Test (std::string name, std::string description="") |
| Test constructor.
|
|
virtual | ~Test () |
| Test destructor.
|
|
const std::string | getName () const |
| getName Getting test name.
|
|
const std::string | getDescription () const |
| getDescription Getting test description
|
|
void | setDescription (const std::string description) |
| setDescription Sets an optional string which describes the test.
|
|
|
void | setName (std::string name) |
| setName setting the test name
|
|
The base class to implememnt a test case.
The user defined test cases should be inherited from TestCase class and the run()
method must be overriden. The 'setup(int argc, char** argv)'
and tearDown()
can be also inherited to implement any initialization or finalization of the test case.
Here's an example of using a TestCase:
#include <cstdio>
#include <iostream>
{
public:
MyTest() :
{
}
bool setup(int argc, char** argv) override
{
return true;
}
void tearDown() override
{
}
void run() override
{
int a = 5;
int b = 3;
}
};
int main(int argc, char** argv)
{
MyTest atest;
}
#define ROBOTTESTINGFRAMEWORK_ASSERT_ERROR(message)
Assertion with throwing error exception.
#define ROBOTTESTINGFRAMEWORK_TEST_CHECK(condition, message)
ROBOTTESTINGFRAMEWORK_TEST_CHECK combines ROBOTTESTINGFRAMEWORK_TEST_REPORT and ROBOTTESTINGFRAMEWORK...
#define ROBOTTESTINGFRAMEWORK_TEST_FAIL_IF_FALSE(condition, message)
Conditional failure report.
#define ROBOTTESTINGFRAMEWORK_TEST_REPORT(message)
Reporting a message to the TestResult.
class ConsoleListener listens to any messages reported by the tests during the test run,...
The base class to implememnt a test case.
The TestResultCollector class can be used to store all the events issued by the test cases,...
unsigned int failedCount()
failedCount gets the number of failed test cases.
The TestResult class is used to deliver the test results including any error and failures produced by...
void addListener(TestListener *listener)
Adding a new listener.
- Examples
- simple.cpp, simple_collector.cpp, simple_fixture.cpp, simple_runner.cpp, simple_suite.cpp, and simple_web.cpp.
Definition at line 41 of file TestCase.h.
◆ TestCase()
robottestingframework::TestCase::TestCase |
( |
std::string |
name, |
|
|
std::string |
param = "" |
|
) |
| |
TestCase constructor.
- Parameters
-
name | The TestCase name |
param | The optional parameters for the test case |
◆ ~TestCase()
virtual robottestingframework::TestCase::~TestCase |
( |
| ) |
|
|
virtual |
◆ failed()
void robottestingframework::TestCase::failed |
( |
| ) |
|
failed Sets the test successful flag to false
which indicates that the test was not successful.
◆ getEnvironment()
std::string robottestingframework::TestCase::getEnvironment |
( |
| ) |
|
getParam gets the environment string which is set for the test case
- Returns
- A environment string
◆ getParam()
std::string robottestingframework::TestCase::getParam |
( |
| ) |
|
getParam gets the original paramter string which is set for the test case
- Returns
- a string paramter
◆ getRepetition()
unsigned int robottestingframework::TestCase::getRepetition |
( |
| ) |
|
getRepetition gets the tun repetition
- Returns
- the number of repetitions
◆ getResult()
TestResult * robottestingframework::TestCase::getResult |
( |
| ) |
|
◆ interrupt()
void robottestingframework::TestCase::interrupt |
( |
| ) |
|
|
overridevirtual |
◆ run() [1/2]
virtual void robottestingframework::TestCase::run |
( |
| ) |
|
|
pure virtual |
◆ run() [2/2]
void robottestingframework::TestCase::run |
( |
TestResult & |
rsl | ) |
|
|
overridevirtual |
◆ setEnvironment()
void robottestingframework::TestCase::setEnvironment |
( |
const std::string |
environment | ) |
|
setEnvironment Optioanlly specifies the environment in which the test case is executed.
The TestCase class does not make any use of it. The environment can be used in the implementation of the test cases to know in which setup (e.g., simulation, real world environment) the test case is employed.
- Parameters
-
environment | The optional environment string |
◆ setParam()
void robottestingframework::TestCase::setParam |
( |
const std::string |
param | ) |
|
setParam Sets the optional parameters of the test.
The parameter string is parsed into (argc/argv) format and will be passed to the test case using setup(int argc, char** argv).
- Parameters
-
◆ setRepetition()
void robottestingframework::TestCase::setRepetition |
( |
unsigned int |
rep | ) |
|
setRepetition sets the run repetition by default the run() method is called only once; The number of test runs (e.g., for stress testing) can be set using this function.
- Parameters
-
◆ setup()
virtual bool robottestingframework::TestCase::setup |
( |
int |
argc, |
|
|
char ** |
argv |
|
) |
| |
|
virtual |
◆ succeeded()
bool robottestingframework::TestCase::succeeded |
( |
| ) |
const |
|
overridevirtual |
◆ tearDown()
virtual void robottestingframework::TestCase::tearDown |
( |
| ) |
|
|
virtual |
◆ environment
std::string robottestingframework::TestCase::environment |
|
private |
◆ interrupted
bool robottestingframework::TestCase::interrupted |
|
private |
◆ param
std::string robottestingframework::TestCase::param |
|
private |
◆ repetition
unsigned int robottestingframework::TestCase::repetition |
|
private |
◆ result
TestResult* robottestingframework::TestCase::result |
|
private |
◆ successful
bool robottestingframework::TestCase::successful |
|
private |
The documentation for this class was generated from the following file:
- src/robottestingframework/include/robottestingframework/TestCase.h