Skip to content

Test Setup

The test runner will search for test cases within test project folders. A test project folder is any folder placed at the root level of a solution, which is named with the prefix Test_. A solution may have more than one test project folder. The reason for limiting test cases to test project folders is to make the removal of tests from a solution easier during deployment.

A test case is a function within a test project folder or any of its subfolders, which is named with the prefix Test_.

A test fixture is any folder within a test project folder, including the test project folder itself, which contains one or more test cases. Test fixtures may contain fixture set up and tear down functions, as well as test level set up and tear down functions.

To indicate a fixture set up function, name it with the prefix Fixture_Set_Up_. Use the prefix Fixture_Tear_Down_ to indicate a fixture tear down function. Each of the fixture set up functions found in a test fixture will be executed once, in alphanumeric order by name, before all the test cases are executed, after which each of the fixture tear down functions will be executed once, again in alphanumeric order by name.

To indicate a test level set up function, name it with the prefix Set_Up_. Use the prefix Tear_Down_ to indicate a test level tear down function. Each of the set up functions found in a test fixture will be executed once, in alphanumeric order by name, before the execution of every test in the fixture. Similarly, each of the tear down functions will be executed once, in alphanumeric order by name, after the execution of every test.

Fixture and test level set up and tear down functions are executed in alphanumeric order so that the test writer can control the sequence. For example, it might be necessary to start a service at fixture set up and then log in to it in a subsequent fixture set up function. More about starting and stopping services will follow shortly.

Test cases within a test fixture are not guaranteed to run in any specific sequence. Importantly, test cases should be written in such a way that they are independent of each other so that they can run in any order or by themselves, as per the Independent Test pattern.