The FixtureManager can be used to to setup any fixture which is required for the tests before executing the tests by a TestSuite.
The fixtureCollapsed method of the FixtureEvents class is used by a fixture manager to inform any class which inherited from FixtureEvents that the corresponding fixture has been collapsed.
Here's an example of using a FixtureManager:
#include <cstdio>
{
public:
MyTest1() :
{
}
{
}
};
{
public:
MyTest2() :
TestCase("MyTest2")
{
}
void run() override
{
}
};
{
public:
MyFixture(FixtureEvents* dispatcher) :
FixtureManager(dispatcher)
{
}
bool setup(int argc, char** argv) override
{
printf("Myfixture setup!\n");
return true;
}
bool check() override
{
printf("Myfixture checking ...\n");
return true;
}
void tearDown() override
{
printf("Myfixture tear down!\n");
throw FixtureException(TestMessage("MyFixture cannot tear down!"));
}
};
int main(int argc, char** argv)
{
MyFixture fixture(&suite);
suite.addFixtureManager(&fixture);
MyTest1 test1;
MyTest2 test2;
suite.addTest(&test1);
suite.addTest(&test2);
}
#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 FixtureManager can be used to to setup any fixture which is required for the tests before executi...
The base class to implememnt a test case.
virtual void run()=0
run is called by the TestCase class if setup is successfull;
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.
The TestRunner class runs the tests added as TestCase or TestSuite.
void run(TestResult &result)
Run all the tests in the list.
void addTest(Test *test)
Adding a new test.
The TestSuite holds a group of tests.
- Examples
- simple_fixture.cpp.
Definition at line 63 of file FixtureManager.h.