Jan/082
Test Your Code
In the earlier tip I was talking about fixing and testing your stuff right away. Now, the testing part is very interesting and a large subject.
When I first started working at Hybrid Graphics (which turned in to Nvidia Finland) I was surprised how much testing they did, but I didn’t quiet understand it. I hated doing the tests. Now after writing nearly twenty thousand test cases (I should win a price with that!) I understand why we did so, and now I love writing tests, because I know that it is the only thing that proves that my software works and so measures it’s quality. And I want to be proud of my code, and so should every programmer be – but that is not always the case.
There are three ways of doing the test before, at the same time or after the implementation. All of these are okay, but the first two ways work better than the third. The third is mostly for finishing up.
First, before doing the implementation, also known as test-driven development. It means as simple thing as writing the test for you implementation before you write it, nothing else. This is one of my favorite, when you start implementing and you’ll have ready test to test whetever it is working or not is amazing!
Second, at the same time with implementation, this is good too and used with the first one. You can’t know everything before you have done something, so sometimes tests have to be added in middle of implementation. Don’t forget to add tests for the bugs you find (critical ones).
So, the best kind of thing comes out when you use all of these.
Few really important things to note is that when you make a test :
- Be sure the test is testing the right thing!
- Also there is no reason to write low quality code in tests, apply the same rules as in implementation!
- Remember that you can also test your frame-buffer, was the pixel drawn in the right place? (CRC is good for these test checks)
- Use nightly builds to check regression!
I still should write more about testing but I’ll leave it to another tip as there is still loads to be discovered.
Enjoy this article?
Leave a comment
No trackbacks yet.
12:04 am on January 6th, 2008
Having a 3rd party to test your code (one with no experience of how it works) is something we all need. I NEED! HELP! (I’d also like the ability to share the code on a trust basis).
6:12 am on January 7th, 2008
Tim, I might be able to help you out, depending on what kind of help you need. E-mail (arex@dawnbringer3d.com) me some details and I’ll see what can I do.