Thursday, April 17, 2008

Scenario Driven Testing

Cedric's recent (ok, it's not that recent) blog on ROR prompted me to write this entry. No, I'm not about to become a RORing ROR advocate, instead I'm going to talk about testing. An interesting point raised by CEdric was this: JUnit actually holds back Java testing scenario and therefore Java is stucked with unit testing as the ultimate and unquestionable master of test and anything less (or more) is frowned upon with so much prejudice it makes "think of the children" slogan sounds holy (dramatization is mine).

Ok, unit testing is in and on itself is not evil, but it's not enough. Functional testing, in my opinion is waaayy more important and yet functional test has been like that uncle everyone despises: can't live with him, can't throw him out of the boat while you pretend going fishing with him at 3:00 AM in the morning.

But how do you do functional test?

Here's my take on it:

When you start your software development you would have scenarii (of course unless you're doing Agi-hi-le development where you code as soon as the client opens his mouth -- just joking, I know agile folks have user stories :) ). The scenarios are not and can never be comprehensive but it gives you the ability to cover the usual usage of your software (which is probably 90% of the time - give or take). All you have to do now is to create scripts mimicking the scenarii and that's it.

Scenario driven testing coupled with unit test would be a great tool for developers: unit testing covers the nitty gritty part of your system and scenario driven testing covers the large picture.

Of course, most of the time you will need to do scenario driven testing through an interface so tools like httpunit would help. But what if you need (or forced) to use an interface toolkit that has no testing framework in sight? *cough* woodstock *cough* (BTW, if anyone knows a good interface based woosdtock testing tool, please show me the light) Well, apart from testing manually, I'm still working on a way to automate things a little. So stay tune...

No comments: