Boost logo

Boost :

From: Mike Attili (yahoomail_at_[hidden])
Date: 2001-10-24 00:46:53

> From: Gennadiy E. Rozental [mailto:rogeeff_at_[hidden]]
> Subject: [boost] Re: unit test framework

> > In this specific context, isn't it possible to use the two arg
> > version? What else might the return type be when counting the
> > number of parameters supplied to a test case? If possible, that
> > would be better than a specific fix for native MSVC STL.
> There are more "fair" compilers, that do not provide 2 arg version.

Whatever works, cross-platform, is fine with me.

> > I did something like the following:
> >
> > class BOOST_AUTO_TEST_SUITE(MyTestSuite)
> > {
> > public:
> > MyTestSuite() { ... } // Optionally setup test fixture
> > ~MyTestSuite() { ... } // Optionally tear down test fixture
> >
> > BOOST_UNIT_TEST(MyFirstTest)
> > { ... }
> > BOOST_UNIT_TEST(MySecondTest)
> > { ... }
> > void HelperFunction()
> > { ... }
> > };
> I would like to see more details on this machinery:

I've uploaded a modified version of auto_unit_test.hpp to the
vault. It works with the unit_test.hpp that you uploaded a few
days ago with one minor modification: test_case::name() and
test_case::timeout() need to be made public.

I've also included two example files. The first is a modification
of the unit_test_example.cpp to take advantage of the features
in auto_unit_test.hpp. It keeps the same test suite structure and
produces the same test results. auto_test_example.cpp is a
reworked version of the same example but makes better use of
auto_unit_test.hpp and, I hope, is more readable and maintainable.

To use these examples, main() in unit_test_main.cpp needs to be
changed to grab the global test suite with the line:
    boost::test_suite * test =
instead of the call to init_unit_test_suite.

auto_unit_test.hpp does not add any new dependencies to the test
framework. The addition of the BOOST_UNIT_TEST,
BOOST_AUTO_TEST_SUITE behavior was done as an independent layer
on top of unit_test.hpp, so it's a step towards the layered approach
suggested by others.

Please let me know what you think. I know that the macros (gasp!)
are a bit hairy, but they do the job succinctly. I'm happy to make
changes or provide additional documentation, etc.

    Mike Attili
    Amaxo, Inc.

Boost list run by bdawes at, gregod at, cpdaniel at, john at