Re: [Perlunit-devel] Greetings
Status: Beta
Brought to you by:
mca1001
From: Piers C. <pdc...@bo...> - 2001-12-12 09:26:53
|
Matthias Ferber <mf...@hi...> writes: > On Tue, 11 Dec 2001, Adam Spiers wrote: >> > > It also occurred to me that a "nice-to-have" would be a verbose option >> > > where it displays the name of each test and the TestCase class as it >> > > progresses. >> > >> > Again, that's something to hang off the runner, and it definitely >> > looks possible. >> >> Yep. Can you give us an example of the output you'd like to see? (Or >> a patch ;-) > > Yeah, sure. I hadn't thought it through in detail but it shouldn't be > hard to work up a simple patch. If I find time to do that, what should I > do with it exactly? Send diffs? Diffs would be good. If you start making more and we like them I'll see about giving you write access to the CVS repository. >> sub test_case { >> my $self = shift; >> ... >> $self->print('some debugging\n'); >> ... >> } >> >> and the debugging will only appear if the test case fails. This is >> currently only supported by TestRunner.pm. Maybe we should think of >> a better name than print(). > > This sounds pretty cool. What's the thinking behind making $self->print() > output only show up when tests fail? I'm guessing that the idea is that > you can print details of what's going on in the test so that when the test > fails you have to do less digging to find the problem, but it doesn't > clutter up the screen when the test succeeds. Yup. Remember that the print message gets sent to the Listener/TestRunner. If you want a more verbose style you can easily (must check that statement) subclass the TestRunner and change that behaviour. > If that's correct I think it's great. I wrote some tests in JUnit > the other day where I could have really used this feature: I had to > do a bunch of messing around with StringBuffers to cram a whole lot > of data into the failure message. > > How about $self->print_on_fail()? Nope. Deciding when/whether to print the message is a function of the runner not of the testcase. C<$self->send_diagnostic(...)> anybody? Hmm... >> > And Test::Unit::Web would be nice, and something to do mock objects, >> > and... > > Hmm... I'm not sure what Test::Unit::Web is meant to be, but... it > so happens that my first trial use of PerlUnit has been to do some > stock web site testing. We host a few hundred web sites, the > majority of which are functionally identical but the rest of which > differ to varying degrees, so I took pains to make the code general > and reusable. If that's what Test::Unit::Web would be about, my base > class could possibly make a decent starting point. It tests that a > page loads successfully within a customizable number of seconds, and > provides some facilities for testing the contents of the page. More > could easily be added. Anyone interested? Ooh, yes please. That's pretty much exactly what I was thinking of. -- Piers "It is a truth universally acknowledged that a language in possession of a rich syntax must be in need of a rewrite." -- Jane Austen? |