How To Use
 All Modules Pages
C++ Example for test case source file
#include "stdafx.h"
/// [testcase.cpp includes]
#include <TestToolBox\TestToolBox.h>
namespace TTB = TestToolBox;
/// [testcase.cpp includes]
//-----------------------------------------------------------------------------
/// [testcase.cpp test suite fixture]
class MyTestSuiteFixture
{
public:
MyTestSuiteFixture()
{
// Log to test protocol
TTB_INFO("\nMyTestSuiteFixture-Constructor");
// Do some preparations needed before each test case
// within this file / test suite
// ...
}
~MyTestSuiteFixture()
{
// Log to test protocol
TTB_INFO("\nMyTestSuiteFixture-Destructor");
// Reset some settings possibly changed by a preceding test.
// For example reset XmlCheck to default settings:
TTB::TheXmlCheck()->SetDefaults();
// Other reset actions
// ...
}
};
/// [testcase.cpp test suite fixture]
/// [testcase.cpp file contents]
// Define fixture which is executed for each test case within this file
BOOST_FIXTURE_TEST_SUITE(SuiteTestingSomeSubject, MyTestSuiteFixture)
//-----------------------------------------------------------------------------
// Represents test case visible for both Boost and TestToolBox
TTB_BOOST_TEST_CASE(DemoTestCase)
{
int a = 4;
int b = 2;
// You can use Boost check macros
BOOST_CHECK(a == 2 * b);
// You can use TTB check macros
TTB_CHECK_EQUAL(a, 2 * b);
TTB_ACT_S("a=" << a << ", b=" << b);
TTB_EXP("a=4, b=2");
// more meaningful checks
// ...
}}; // yes, there are double paranthesis!
//-----------------------------------------------------------------------------
// continue with other test cases
// ...
//-----------------------------------------------------------------------------
// closing tag for test suite
BOOST_AUTO_TEST_SUITE_END()
// end of cpp file
/// [testcase.cpp file contents]