Boost logo

Boost Users :

From: Ovanes Markarian (om_boost_at_[hidden])
Date: 2007-01-25 14:00:16


Gennadiy,

sorry to be off-topic. Just a general question on your statement:

> I recommend you to avoid init_unit_test_suite and use BOOST_AUTO_TEST_CASE
> instead.

Do you generally recommend to avoid init_unit_test_suite? If yes, could you explain why?

I have some hierarchy of unit tests which might depend on other tests. And in case of avoiding
init_unit_test_suite, I would need to introduce one more level in the hierarchy, since in my case
test_suite can depend on some other test_suits. Currently this kind of dependency is added in
init_unit_test_suite.

Thanks,
Ovanes

On Thu, January 25, 2007 17:34, Gennadiy Rozental wrote:
> "Stephen Torri" <storri_at_[hidden]> wrote in message
> news:1169597636.8109.18.camel_at_base.torri.org...
>>I have the following code for a sample test. I was wondering how I can
>> move code that is common to a long off different test files to a common
>> location and use inheritance?
>
> Why would you want to use an inheritance (just a general question)?
>
>> In the code below I can do two things. If
>> its indeed generic I can encapsulate it in a common class used in the
>> tests. Secondly I could put test_one and test_two in a class and inherit
>> from the parent generic class. What is the best solution for what I am
>> trying to do?
>
> To be frank with you I do not see anything particular generic in the code
> below and don't really understand what you are trying to do. Could you
> please give some more detailes. Than I probably be able to give some
> recommendations.
>
>> Stephen
>>
>> ----------CODE--------------
>>
>> #include <boost/test/unit_test.hpp>
>> #include <fstream>
>>
>> using namespace boost::unit_test;
>> using namespace boost::unit_test_framework;
>
> You don't need secont using statement. Both namespaces are synonims.
>
>> class A {}
>> class B {}
>>
>> A*
>> helper_run_test ( B& target_ref,
>> std::string target_file )
>> {
>> ... do work on B and return A* result
>> }
>>
>> void test_one ()
>> {
>> B& b_ref;
>
> That's invalid
>
>> A* helper_run_test ( b, "Apple" );
>> .. perform a BOOST_CHECK_EQUAL
>> }
>>
>> void test_two ()
>> {
>> B& b_ref;
>> A* helper_run_test ( b, "Peach" );
>> .. perform a BOOST_CHECK_EQUAL
>> }
>
>> test_suite*
>> init_unit_test_suite ( int, char**)
>> {
>> test_suite* test = BOOST_TEST_SUITE ("My test suite");
>>
>> test->add ( BOOST_TEST_CASE ( &test_one ) );
>> test->add ( BOOST_TEST_CASE ( &test_two ) );
>>
>> return test;
>> }
>
> I recommend you to avoid init_unit_test_suite and use BOOST_AUTO_TEST_CASE
> instead.
>
> Gennadiy
>
>
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>


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