The base class to implememnt a test case.
More...
#include <robottestingframework/TestCase.h>
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;
}
{
}
{
int a = 5;
int b = 3;
}
};
int main(int argc, char** argv)
{
MyTest atest;
atest.TestCase::run(result);
}
- 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