On Wed, 02 Jan 2008 04:57:28 +0100, Gennadiy Rozental
wrote:
Why don't you post specific problems with faling test modules examples.
My problem is easy. I want to have one main test that add Second and so
on. I cannot get it to work :/ What's the best practice? Is
BOOST_CLASS_TEST_CASE a good approach on Second? I cannot get add to work
:/ I definitely need an example with two file, parent and child test
example.
Thanks in advance,
Tomasz Kalkosiński
//First
#include
#include "second.cpp"
using boost::unit_test::test_suite;
// most frequently you implement test cases as a free functions
void free_test_function()
{
// reports 'error in "free_test_function": test 2 == 1 failed'
BOOST_CHECK(2 == 1); // non-critical test => continue after failure
int* p = (int*)0;
*p = 0;
}
test_suite*
init_unit_test_suite( int, char* [] ) {
test_suite* test= BOOST_TEST_SUITE( "Unit test example 1" );
// this example will pass cause we know ahead of time number of
expected failures
test->add( BOOST_TEST_CASE( &free_test_function ), 1 /* expected one
error */ );
test->add (new Second ());
return test;
}
//EOF
//Second
#include
using boost::unit_test::test_suite;
class Second : public test_suite
{
public:
Second () :
test_suite ("Second test suite")
{
add (BOOST_CLASS_TEST_CASE(&free_test_function2));
}
// most frequently you implement test cases as a free functions
void free_test_function2()
{
// reports 'error in "free_test_function": test 2 == 1 failed'
BOOST_CHECK(2 == 1); // non-critical test => continue after
failure
int* p = (int*)0;
*p = 0;
}
} ;