Testing, or when your application gets complex!

There's really no good reason for not starting to write tests right from the start of any project you work on. Some people like the test driven development way of doing things, some don't. Hopefully most developers have come to the conclusion that when writing software, you really need to test your work. Most of my work start out as some sort of hobby project or POC, so most of the time I don't start writing tests from day 1. Of course I should, but I like being honest, so honestly: I don't!

In the first couple of months of working with the MVC Forum project, it hasn't been that hard testing the software, but even so, version 0.6 was released with a stupid error in the Forum Admin area that means you can't edit an user! Stupid! I should have caught that. I put my focus into testing that users could sign up, create topics, post replies and that is about it. The Forum Admin area hasn't been tested at all.

What happens is that somewhere along the way your project crosses a boundary where it gets too complex to totally understand the impact of the changes you make. If you sat down and considered each and every change, you would probably know exactly what would break, but you have to make progress and really don't have the time. And why would you want to do that anyway, when you could use the time adding code and features to your project? Which is what really matters to the users. Or maybe not! I bet they would prefer less features in a well-tested solution to large amounts of untested features.

MVC Forum has crossed that boundary months ago, and with the up-coming version 0.7, we're seriously past the point of no return. With the anti-spam measures and search indexing, the amount of senarios you have to work your way through to test each and every pitfall, would take days (and a very long list with the senarios, so you don't forget one!).

So I've come to the conclusion that it's time to start testing the UI, and for that I'm going to use NUnit (for executing the tests) and Selenium (the web drivers, for interacting with MVC Forum through a browser). Yes, this will take time away from putting more code and features into the MVC Forum project, but at least it still involves code! And the added benefit is that it will most likely catch some errors, and might even make me think about how different features work or should work. Of course this testing is done automatically, use the NUnit test runner or the Visual NUnit Visual Studio add-on for this. Once you've written a test, that test is valid until you change the way the tested feature works, so over time the amount of tests and areas tested, will just grow and grow. Who knows, we might get close to the magic 100% test coverage one day.

Yes, this ended up as a no-code post, I'm sorry! I promise I'll post some code next time. About next time, hopefully MVC Forum version 0.7 (Alpha 3) is released in a few days, so hopefully I'll be back with some info on the theme of the next release (being version 0.8).

Categories: MVC Forum - NUnit - Selenium

Posted by Steen F. Tøttrup on 16 November 2011 06:54. There are 0 comments.

Write new comment