Fixture definition (C and C++)
Table of Contents
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 |
|---|---|
| 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. |




![[Note]](images/note.png)