Game Development Reference
In-Depth Information
Testing code methods or functions that are essential parts of a game engine or
middleware product
Testing code modules within your game that might be used by third-party
developers or “modders�? who, by design, could expand or modify the behavior
of your game to their own liking
Testing low-level routines that your game uses to support specific functions in
the newest hardware devices such as graphic cards or audio processors
In performing white box testing, you execute specific modules and the various paths
that the code can follow when you use the module in various ways. Test inputs are
determined by the types and values of data that can be passed to the code. Results are
checked by examining values returned by the module, global variables that are affected
by the module, and local variables as they are processed within the module. To get a
taste of white box testing, consider the TeamName routine from Castle Wolfenstein: Enemy
Te r r i t o r y :
const char *TeamName(int team) {
if (team==TEAM_AXIS)
return “RED�?;
else if (team==TEAM_ALLIES)
return “BLUE�?;
else if (team==TEAM_SPECTATOR)
return “SPECTATOR�?;
return “FREE�?;
Four white box tests are required for this module to test the proper behavior of each
line of code within the module. The first test would be to call the TeamName function
with the parameter TEAM_AXIS and then check that the string “RED�? is returned. Second,
pass the value of TEAM_ALLIES and check that “BLUE�? is returned. Third, pass TEAM_SPECTATOR
and check that “SPECTATOR�? is returned. Finally, pass some other value such as TEAM_NONE ,
which makes sure that “FREE�? is returned. Together these tests not only exercise each
line of code at least once, they also test the behavior of both the “true�? and “false�?
branches of each if statement.
This short exercise illustrates some of the key differences between a white box testing
approach and a black box testing approach:
Black box testing should test all of the different ways you could choose a test
value from within the game, such as different menus and buttons. White box
testing requires you to pass that value to the routine in one form—its actual
symbolic value within the code.
Search WWH ::

Custom Search