Game Development Reference
In-Depth Information
scalability, decentralized, fully distributed collaborative development. Git
and Mercurial have similar aims.
If you really want to be at the cutting edge of revision control, then look into
Git or Mercurial. If you want simple and easy to use, my recommendation is
Subversion.
Unit Testing
When a programmer writes some new functionality, he'll usually write a snippet
of code to test it. Unit testing is just a clever way of gathering these little snippets
of code together. Then they can be run each time the code is compiled. If sud-
denly a previously working test fails, it is obvious that something is broken. As
the word ''snippets'' suggests, unit tests should be very small pieces of code that
test one thing and one thing only.
In the unit-testing world, it's very common to write the tests first and then code.
This might be best illustrated with an example. Let's say we are creating a game
and a class is needed to represent the player. Players should have a health status,
and when you create a player, he should have greater than zero health. Let's write
that in code form
class PlayerTests
{
bool TestPlayerIsAliveWhenBorn()
{
Player p ΒΌ new Player();
if (p.Health > 0)
{
return true; // pass the test
}
return false; // fail the text
}
}
This code won't compile yet as we haven't even created a player class. But I think
the test is pretty self-explanatory. If you create a player, he should have greater
than zero health; otherwise, this test fails. Now that the test is written, let's create
the player.
 
Search WWH ::




Custom Search