Visual Assert – The Unit Testing Add-In for Visual C++
cfix – C/C++ Unit Testing for Win32 and NT
 
 

Fixture definition (C and C++)

Fixture definition (C and C++)

Fixtures are defined with the CFIX_BEGIN_FIXTURE/CFIX_END_FIXTURE construct, as shown in the following example:

#include <cfix.h>

void __stdcall Setup() 	  { ... }
void __stdcall Teardown() { ... }
void __stdcall Before()   { ... }
void __stdcall After()    { ... }
void __stdcall Test1()    { ... }
void __stdcall Test2()    { ... }

CFIX_BEGIN_FIXTURE( FixtureName )
	CFIX_FIXTURE_SETUP( Setup )
	CFIX_FIXTURE_TEARDOWN( Teardown )
	CFIX_FIXTURE_BEFORE( Before )
	CFIX_FIXTURE_AFTER( After )
	CFIX_FIXTURE_ENTRY( Test1 )
	CFIX_FIXTURE_ENTRY( Test2 )
CFIX_END_FIXTURE()
		

To avoid having to forward declare the routines, it is usually adisable to put this fixture definition at the end of a file. Note that all of these entries are optional.

[Note]Note
The order and positioning of FIX_FIXTURE_SETUP, CFIX_FIXTURE_TEARDOWN, CFIX_FIXTURE_BEFORE, and CFIX_FIXTURE_AFTER entries is irrelevant. The order of CFIX_FIXTURE_ENTRY entries, however, defines their execution order.