Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

gav (2710)

gav
  (email not shown publicly)
http://www.estey.com/
AOL IM: flufflegavin (Add Buddy, Send Message)

Hacker in NYC.

Journal of gav (2710)

Tuesday November 30, 2004
11:09 PM

Domain Specific Testing

[ #22086 ]

One of the things I do is implement tax and shipping rules for clients. As an interesting aside, we use a early web services technique invented at Yahoo! where we recieve a POST of all the data and return the results in custom headers. Anyway, as you can expect, it's often a challenge to capture the exact rules required and they tend to be pretty complicated.

I'd just been working on adding rules for AK and HI for a client that only previously shipped to the 48 contiguous states and the added complexity made me worried that I made a mistake. I wanted to write tests, but I wanted something at a higher level than just writing Perl code, and more importantly I wanted a test suite that the client can add to. I came up with the following format:

product: 9848rdc
quantity: 1
options: Size: 148
product: 9852rdc
quantity: 2
options: Size: 152
state: AK
country: US
method: Ground
cost: 24.95
--
product: bk7ma
product: 9848rdc
options: Size: 148
state: AK
cost: 39.95
method: Ground

I then wrote a script that reads this in, turns each section into three tests (using Test::More): we were able to POST, we didn't get back an error, and we got back the right cost. We've now got a format that allows non-programmers to write tests, and they're often the best people to write them because they know what they expect the system to do.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • I think this gets close to one of the ideas for wiki usage. I remember reading that an implementation goal of the wiki framework was to set up editable web pages that end users could use to design tests for code. Then the users can build the acceptance tests and see the results right away. Very cool idea, and it looks like you're almost implemented it!
    • Thinking of FIT [c2.org] or Test::FIT [cpan.org]? These are nifty, but I have a sneaking suspicion that customers who use such systems are are more willing to learn than the ones I normally deal with.