Xna Unit Testing

Jan 21, 2010 at 10:47 PM

This is really interesting, and I'm glad to see someone taking a stab at it! I'm sure many are thinking along the same lines like me and attempting to unit test their XNA code.

One hurdle I tend to consistently battle with is the relativity or complexity of results in this kind of coding with XNA.  For example, I may have a camera, and I may want to test that when I say OrbitLeft, it orbit's left around a particular target.  Well, such a camera may simply output a world transform.  Do I really want to be testing the transformation matrix result that it is "more left in rotation then the previous matrix?"

The other hurdles I notice is that 3d/2d high perf game programming like this does not lend it self to testable architectures very well.  The overhead of ceremonial code often found in your daily line of business app make game developers sometimes cringe.  Albeit, I see huge benefits (like dependency injection makes pluggable strategies so easy, and can keep rendering code away from update logic code).

I'm sure I'm not thinking of solutions deep enough, I'm sure there's enough answers somewhere, but such complexity of testing takes away some of the reason why I want to do Xna as a hobby. :)

Keep up the work, I'll be following.

-Chris

Coordinator
Jan 29, 2010 at 3:19 PM
Edited Jan 29, 2010 at 4:20 PM

Hi Chris, I'm glad you are liking it so far.  To address some of your points:

The first scenario you are describing sounds like testing base engine-level code.  In this case, there is in fact a very explicit mathematical result which should be true once you have orbited left around a target ... so yes, this would likely be a good test to assert on the resulting transformation matrix.

As to testable architectures, this is actually one of the main points this project was meant to address. Because scurvy.test lets you run the code in-line with the application ... it means that you have other resources at hand such as the graphics object.  So your unit tests can load content, render objects for manual verification (using the exit criteria feature). Now, you don't have to spend so much energy trying to factor your code in such a way as to abstract these things out ... you can just use them.

I'm definitely open to feedback about how the users think this should evolve.  I think it serves an important niche which hasn't really been addressed in other products.