|
Boost Users : |
From: Gennadiy Rozental (gennadiy.rozental_at_[hidden])
Date: 2006-03-06 11:40:08
"Mateusz Loskot" <mateusz_at_[hidden]> wrote in message
news:dufmfr$hem$1_at_sea.gmane.org...
> Hi,
>
> I'd like to ask yet another questions related to Unit Test Framework
> usage. Especially, I'm interested in best practice of Unit Tests
> organization in the project.
>
> I have a project that consists of more than 100 classes.
> Some of those classes are general purpose (e.g. Point) but some are
> organized in components (e.g. spatial index component consisting of 5
> classes).
>
> Now, I'd like to add Unit Tests (yes, I know I should have them prepared
> before I created those classes ;-)).
>
> I've read almost all docs about Boost.Test, downloaded from CVS.
Docs are not ready yet. Most of it is either outdated or incomplete.
> I know how to create Test Case and how to combine those cases into Test
> Suite. I also read introductory docs from "Tutorials and usage
> recommendations" part as well as I walked through unit_test_examples but
> I'm still a bit confused about the bigger picture.
>
> As far as I understand, every Test Case or Test Suite of cases is to be
> compiled to separate executable. Is this correct?
No. You could have any number of those in a single test module. You sould
use your own judgement to decide when to split your test module into
separtate executable. Usually reasons more or less clear:
* Different units/subsytem needs to have separate executable
* If some feature may casue compilation error - move it into separate
module.
* If number of test module execution time exceed some limit (your
choice) - split it.
> So, unit_test_example_01.cpp and unit_test_example_02.cpp and so on
> create separate programs that can be executed e.g. from Visual Studio
> Post-Build Event as explained in docs.
>
> More precisely, every .cpp file that:
> - include #include <boost/test/unit_test.hpp>
> - uses defines cases using BOOST_AUTO_TEST_CASE
> - or defines suites of cases using BOOST_TEST_SUITE + BOOST_AUTO_TEST_CASE
BOOST_AUTO_TEST_SUITE
> will be a separate program. Right?
No. You could combine several test files into single test module. Don't
forget - BOOST_TEST_MAIN/BOOST_TEST_MODULE should be defined into single one
only.
Gennadiy
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net