Hi Ovanes,

 

this is, why I added 'printf("Initializing\n"); to init_unit_test() in my DLL. As this is indeed printed before the error message, I think that the lib is found and loaded.

 

Furthermore, if the lib cannot be found, I get:

C:\Projekte\Test\NetControl\bin>console_test_runner --test NetCtrl.dll

Boost.Test framework internal error: unknown reason

 

So it seems that the DLL is loaded and init_unit_test() is invoked, but the test cases are not registered …

 

Christian

 

 


Von: boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org] Im Auftrag von Ovanes Markarian
Gesendet: Dienstag, 15. Jänner 2008 18:40
An: boost-users@lists.boost.org
Betreff: Re: [Boost-users] Boost.Test Framework to test a DLL

 

Is there any chance that Boost.Test can not load (find) your DLL? Try to copy console_test_runner into the directory which contains your DLL? Debug DLLs under VC++ have usually a suffix 'D' before .dll. The letter NetCtrl->d<-.dll is probably this suffix. If not, add it, so that the name is NetCtrldD.dll


With Kind Regards,
Ovanes

On Jan 15, 2008 9:55 AM, Plonka Christian <christian.plonka@amst.co.at> wrote:

Hi,

I'm planning to change from CppUnit to Boost.Test for unit testing since
it is now possible to integrate unit tests also in a DLL. Nevertheless I
do encounter some problems here.

The code is (I guess you'll recognize it):

//----------------------------------------------------------------------
---
#define BOOST_TEST_DYN_LINK
#include <boost/test/unit_test.hpp>
using namespace boost::unit_test;

BOOST_AUTO_TEST_CASE( test1 )
// void test1()
{
   int i = 0;

   BOOST_CHECK_EQUAL( i, 2 );
}

BOOST_AUTO_TEST_CASE( test2 )
{
   BOOST_CHECKPOINT("About to force division by zero!");
   int i = 1, j = 0;

   i = i / j;
}

extern "C" {
__declspec(dllexport) bool
init_unit_test()
{
   printf("Initializing\n");
   framework::master_test_suite().p_name.value = "Test runner test";
   // framework::master_test_suite().add( BOOST_TEST_CASE( &test1 ) );

   return true;
}
}
//----------------------------------------------------------------------
---

I the sample (test_runner_test.dll) it works fine but when I use it in
my DLL I get:

C:\Projekte\Test\NetControl\bin>console_test_runner --test NetCtrld.dll
Initializing
Test setup error: test tree is empty

I also tried the commented version using master_test_suite().add()
without any change.

Any hint what I can try or how I can debug this?

Thanks,
Christian


_______________________________________________
Boost-users mailing list
Boost-users@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users