This post originated from an RSS feed registered with Agile Buzz
by James Robertson.
Original Post: On ordering testcases
Feed Title: David Buck - Blog
Feed URL: http://www.cincomsmalltalk.com/rssBlog/buck-rss.xml
Feed Description: Smalltalk can do that
The popular concensus amonst users of SUnit is that the order of testcases doesn't matter and testcases can be run in any order. I agree to an extent. The way SUnit works by default is to pick out all method names starting with "test" and execute them in any order. In most cases this works and I feel that in all cases it should work. My problem is not with the running of the testcases at all. It has to do with failure and with learning
When I write testcases, I write basic ones first to test fundamental things and gradually build up the complexity to more and more sophisticated operations. Suppose I have 50 testcases written that all pass. Now I change the code in some way and 20 of the testcases break. To find out why they broke, I'd like to debug one of them. Which one? I'd really like to debug the simplest one that broke rather than a more complex one. With SUnit, there's no easy way to tell which is the simplest.
Suppose I bring a new developer onto a project. An excellent way to have them learn the system is to get them to walk through the execution of the testcases. To do that, they need to start from the simplest tests. Which are the simplest? It's impossible to tell.
For these reasons, I frequently override the buildSuite method of SUnit and provide my own. This gives my testcases an explicit order and helps me debug them and use them as documentation.