unit testing refers to building software in separate pieces with specific functions. each piece is a "unit". the idea is you break down a complex system into its simpler pieces or units. these are simple enough to build and test individually. an example "unit" might be a bit of code that moves a single unit based on its speed and heading. this would be pretty simple to code and test to make sure its spitting out the right numbers.
along with unit testing (testing the pieces) comes "integration testing". this is where you hook the pieces together, then test to make sure they work together correctly.
an example of this might be something like stringing your "AI", "turn", and "move" code together, and testing it to make sure your AI can actually steer and move your units around as desired. The idea being that you've already built and unit tested the "AI", "turn" and "move" code units, and all you have to do is test to make sure you hooked them up correctly.
with modular/unit design, you determine the basic "units" of your program, such as an input unit, a rendering unit, and an update unit in a game (get_input, drawscreen, move_everything, the 3 basic steps of a game loop). then you break each unit down into smaller components. your input unit will need keyboard handler and mouse handler components, for example. so you write a keyboard handler, and test just that (unit testing). likewise for a mouse handler. then you combine them to make your input unit (i prefer the term module), and test it,. this is actually both integration testing of the keyboard and mouse units, as well as unit testing of the input unit as a whole.
its all about divide and conquer. building and testing large units becomes easy because they're all built from smaller units that have already been tested and are known to be (reasonably) correct.
Edited by Norman Barrows, 12 July 2013 - 05:12 PM.
"DirectX is like a belt fed machine gun, where every texture change is like hand loading in a new belt of ammo. worse, every mesh (vb) is a new belt of ammo, and a texture is like breaking the gun down, and setting it up again elsewhere, then loading it, then spraying triangles again. so you want to setup the gun once, string all your belts together, load it once, then just spray."
Rockland Software Productions
"Building PC games since 1988"
Sign up for the Caveman beta!