title: Is unit testing viable in game programming?
body: <p>I'm fond of the idea of unit testing but I'm having trouble applying it to game programming. Games are highly stateful and often the code doesn't break itself into distinct units. In my experience, most functions mutate state rather than returning values.</p>
  
  <p>Consider a simple action like <code>playerJump(height)</code>. I'd love to have a test suite that checks a large variety of cases to make sure that jumping always works as expected. However this function will likely return no value and have the side effect of, <code>player.velocity.y = -height</code> and <code>checkCollisions(player)</code>. I can't think of a clear unit test to build around this.</p>
  
  <p>Is unit testing just not viable in highly stateful applications like games? Are the advantages of unit testing so great that it would be worth programming games functionally?</p>
  
  <hr>
  
  <p><strong>Update:</strong></p>
  
  <p>Games from Within has a series of in depth articles about using Test Driven Development in games. I highly recommend them to anybody interested in this subject. Here is the first article:</p>
  
  <p><a href="http://gamesfromwithin.com/stepping-through-the-looking-glass-test-driven-game-development-part-1" rel="noreferrer">http://gamesfromwithin.com/stepping-through-the-looking-glass-test-driven-game-development-part-1</a></p>