Boost logo

Boost Users :

Subject: Re: [Boost-users] [Boost] [Test] [1.38] "can't use testing tools before framework is initialized"
From: Greg Christopher (gchristopher_at_[hidden])
Date: 2009-05-18 23:33:48


>> 2. You may not need main. You can do your initialization either in
>> global fixture or in test suite initialization function (like in
>> example
>> above)
>
> Thanks for the great tip-
> I have organized the program to work this way. The sample code doesn't quite work, I had to cast the initialization function that is passed into unit_test_main (boost::unit_test::init_unit_test_func).

Cast to what? init function has right signature.

Greg > The cast is right above you. Yes the signature matched- bool return; void arguments. But VS2008 still complained that I could not pass that into unit_test_main. The cast worked fine, the function got called no problem.

> I did that and I got pretty far but there is a strange runtime error
> that happens here:
>
> test_unit&
> get( test_unit_id id, test_unit_type t )
> {
> test_unit* res = s_frk_impl().m_test_units[id];
>
> if( (res->p_type & t) == 0 )
> throw internal_error( "Invalid test unit type" );
>
> return *res;
> }

What the error message?

Greg> "Invalid test unit type" . ?!

Since I was debugging the program, it stopped on the exception. If I just let it run, that's pretty much the error message. What does that message mean? Somewhere else I saw on the net that it could mean there is no test suite defined but I am hoping I don't need to do that.

> The test case I added was simpler and had no parameters to pass:
>
> framework::master_test_suite().add( BOOST_TEST_CASE(TestMain) );

Please post simple example. I do not follow what is your problem. By the
way what version of Boost r u using?

Greg > 1.38 as the subject says. TestMain is simply a function that returns an int and gets passed a void. I trust the above line is the correct way to add such a function?

> That happens successfully but the main test program never gets called and execution stops at the location above.
>
> I saw this link:
> http://lists.boost.org/Archives/boost/2006/03/102592.php

This issue fixed since. And it was just an issue with proper error report.

> Looks like I do need to autoregister a test suite first? I tried registering one with no luck.

No you don't.

Greg> good.

To summarize:
-The framework is throwing saying "Invalid unit test type"
-I am not defining suites or test cases other than the code you've seen which manually adds them using master_test_suite.add()
-Boost is 1.38

Since I haven't really defined a unit test other than to pass a function, maybe there is some step I need to take?

Greg


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