Unity Test File

Test cases that belong to a group are put in the same file. The typical name for the file is GroupNameTest.c. The GroupName is usually named after the module under test, such as CircularBuffer. When a module needs more than one TEST_GROUP to form a group of tests with common setup, introduce another group like CircularBufferPrint for the tests that are concerned with printing a CircularBuffer.

Here is a summary of the elements of a TEST_GROUP that go in a test file:

 
//test harness include
 
#include "unity_fixture.h"
 
 
//#includes for module under test
 
 
TEST_GROUP(GroupName);
 
 
//Define file scope data accessible to test group members prior to TEST_SETUP.
 
 
TEST_SETUP(GroupName)
 
{
 
//initialization steps are ...

Get Test Driven Development for Embedded C now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.