[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Omaha.pm] Test driven development: RED, GREEN, REFACTOR
- To: "Perl Mongers of Omaha, Nebraska USA" <omaha-pm@pm.org>
- Subject: [Omaha.pm] Test driven development: RED, GREEN, REFACTOR
- From: "Jay Hannah" <jhannah@omnihotels.com>
- Date: Fri, 4 Aug 2006 18:16:47 -0500
- Delivered-to: mailman-omaha-pm@mailman.pm.dev
- Delivered-to: omaha-pm@pm.org
- List-archive: <http://mail.pm.org/pipermail/omaha-pm>
- List-help: <mailto:omaha-pm-request@pm.org?subject=help>
- List-id: "Perl Mongers of Omaha, Nebraska USA" <omaha-pm.pm.org>
- List-post: <mailto:omaha-pm@pm.org>
- List-subscribe: <http://mail.pm.org/mailman/listinfo/omaha-pm>, <mailto:omaha-pm-request@pm.org?subject=subscribe>
- List-unsubscribe: <http://mail.pm.org/mailman/listinfo/omaha-pm>, <mailto:omaha-pm-request@pm.org?subject=unsubscribe>
- Reply-to: "Perl Mongers of Omaha, Nebraska USA" <omaha-pm@pm.org>
- Thread-index: Aca3ExydWK16dNFrSu+MBYvRICtn0ABBCv0AAAEobCA=
- Thread-topic: Test driven development: RED, GREEN, REFACTOR
Hit a bug today. A specific message should have been logged as "WB V9",
not "V9 V9". The code that threw that log entry is
$return = sprintf(
"%s %s %s [%s|%s%s%s%s] [%s|%s%s] %f",
$req->get_gds,
$req->get_sga,
$msn,
... $req here is a Control::Multiplex::Payload::USW object. So, being
the agile developer (and other buzzwordy crap here) that I am I added a
test to USW.t that fails, demonstrating the bug:
$ perl USW.t
1..71
ok 1 - new()
ok 2 - get_payload()
ok 3 - get_type()
...
ok 67 - get_payload()
ok 68 - get_type()
ok 69 - get_segment()
not ok 70 - get_gds()
# Failed test 'get_gds()'
# in USW.t at line 158.
# got: 'V9'
# expected: 'WB'
ok 71 - get_sga()
# Looks like you failed 1 test of 71.
I then found the bug and patched it. And now ALL my tests pass!
$ prove t/USW.t
t/USW....ok
All tests successful.
Files=1, Tests=71, 1 wallclock secs ( 0.63 cusr + 0.06 csys = 0.69
CPU)
Red/green/refactor, baby. I (re)learned that at OSCON last week. :)
http://conferences.oreillynet.com/cs/os2006/view/e_sess/8699
j