Programming Testing: Seams
From wikinotes
Seams are places where you can alter the behaviour of a program when it is under test.
The available seams depend on the programming language in use.
When designing a program for testing, you should provide seams to allow it to be tested.
PreProcessor Seams
TODO:
untested
In C/C++ and other languages with macros,
you can use anIFDEF
to inject or replace test methods.Something like this.
#ifdef TESTING struct User { int id; char *name; } User users[5] = {}; #define create_user(id, name) \ { \ struct User user; \ user.id = id; \ user.name = name; \ users[0] = user; \ } #endif