A test case defines the fixture to run multiple tests.
More...
A test case defines the fixture to run multiple tests.
To define a test case:
1) implement a subclass of MQLUNIT_TestCase
2) define instance variables that store the state of the fixture
3) initialize the fixture state by overriding MQLUNIT_TestCase::setUp
4) clean-up after a test by overriding MQLUNIT_TestCase::tearDown
Each test runs in its own fixture so there can be no side effects among test runs.
For example:
private:
double a, b;
public:
void setUp() { a = 1.0; b = 2.0; };
double result = a + b;
}
MQLUNIT_END
};
The tests to be run can be collected into an MQLUNIT_TestSuite.
suite.
addTest(
new MyFirstTestCase());
suite.
addTest(
new MySecondTestCase());
suite.
addTest(
new MyThirdTestCase());
- See also
- MQLUNIT_TestResult
-
MQLUNIT_TestSuite
◆ MQLUNIT_TestCase() [1/2]
MQLUNIT_TestCase::MQLUNIT_TestCase |
( |
| ) |
|
|
inline |
Constructor : creates a test case using a class name as a test case name.
◆ MQLUNIT_TestCase() [2/2]
MQLUNIT_TestCase::MQLUNIT_TestCase |
( |
const string |
name | ) |
|
|
inline |
Constructor : creates a test case with a provided name.
- Parameters
-
◆ ~MQLUNIT_TestCase()
virtual MQLUNIT_TestCase::~MQLUNIT_TestCase |
( |
| ) |
|
|
inlinevirtual |
◆ run()
virtual void MQLUNIT_TestCase::run |
( |
MQLUNIT_TestResult * |
result, |
|
|
bool |
inherited = false |
|
) |
| |
|
pure virtual |
Runs the tests.
- Parameters
-
result | : collects the results of executing a test case |
inherited | : set to true to tell the test it has been inherited from and is run by a child test |
- See also
- MQLUNIT_TestResult
Implements MQLUNIT_Test.
◆ setUp()
virtual void MQLUNIT_TestCase::setUp |
( |
| ) |
|
|
inlinevirtual |
Set up context before running a test.
◆ tearDown()
virtual void MQLUNIT_TestCase::tearDown |
( |
| ) |
|
|
inlinevirtual |
Clean up after the test run.
The documentation for this class was generated from the following file: