chris.software     development     reviews     feed

Unit Testing for Ne+

I am working on a software testing class and developing my project simultaneously, so to participate in that class I am utilizing test-driven development in my project. I am not yet strictly participating in this type of development because I am still in the design phase, but I did create a project for testing and installed NUnit and TestDriven.NET, so I can basically click a class and run tests on it and get the results immediately. It’s very cool, very powerful stuff - if you use it correctly. I’m still experimenting with the details of testing my classes, and they do have some dependencies that make testing a little more complicated than it would be ideally, but I think I’m definitely on the right path. I just need to experiment some more, and then I should be able to utilize the software I’m using to test to its full potential.

I have looked at a few different methods of testing to use in development, but I think that test-driven material makes the most sense to me, although I probably won’t be adhering strictly to its principles. For instance, although I find the idea of writing your tests before your actual code, there’s no way to know for sure that your interface is still going to be the same when you’re done writing/designing. It’s a nice idea though, that you could potentially write a test that fails, then code to that test, and make it pass. But coding to a test doesn’t seem like the greatest idea 100% of the time - sometimes you just need to focus on design that makes sense to you, rather than an interface that seemed like a good idea when you started. If there’s one thing I’ve learned so far from working in an actual work environment (not just independently), it’s that you need to keep things in a simple, organized fashion so that you or your successor can come back to it without spending too much time re-learning the codebase. Another reason that it’s not always the best answer in my eyes is that there are some results in a video game, or any visual application, that can’t be tested by assertions. Sometimes, a player’s eyes need to see certain visuals to verify results, and certainly no test can tell me if a game “looks good” - I need to visually verify some results myself. I can’t think of, or haven’t yet come across a way, to do these things with test-driven development.

All that said, I’ll be trying to utilize TDD as much as possible. There are many physics, map, and calculation issues that I am dealing with, all of which can benefit by classic usage of the TDD methodologies. I will be attempting to develop to tests whenever it makes sense to me, and trying to come up with other testing strategies for the cases in which TDD doesn’t make as much sense. The Visual Studio 2010 integration with TestDriven.NET is an excellent tool that I highly recommend for anyone who wants to pursue testing with NUnit, because unit tests are a very clean way to test code, and the tools available makes it nearly effortless.