[rspec-users] A recently observed anti pattern: commented out tests

James Cox james at imaj.es
Thu Jul 26 20:08:07 UTC 2012


On Tue, Jul 24, 2012 at 4:54 PM, Chris Flipse <cflipse at gmail.com> wrote:

> On Tue, Jul 24, 2012 at 1:55 PM, James Cox <james at imaj.es> wrote:
>>  so yes, pending is ok, but a second keyword "broken" might be nicer,
>> which would act the same but output different info.--
> There is a block form of pending.  It actually executes the contents of
> the block, but outputs as a pending test -- unless the test passes, in
> which case it fails with a differing message:
>   it "is a broken test that I need to fix sometime" do
>     pending("broke on nonesuch upgrade") {
>       domain.do_failing_thing
>     }
>   end
> So,  that shows up in test output just like every other pending note.
> Whenever someone gets around to fixing whatever failed, the contents of the
> block start passing -- and the test will fail.  The failure is a signal to
> remove the pending block from around the test.
> This may not be as helpful as you like, if it's drowning in a sea of true
> "pending" tests ... but I feel that leaving unimplemented, pending tests in
> the suite for a long time is a Bad Thing -- precisely because you loose
> useful information like this.

One of the examples i've found for commented out tests is when the code
plainly doesn't work. Wouldn't it also fail (and output a backtrace) in
this instance, therefore thoroughly confusing whoever is observing the test
output? I do like the idea of this though: pend it until it passes, and
then fail because you should check it, but … i dont' imagine that it'd
really work that way.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20120726/377b9a90/attachment.html>

More information about the rspec-users mailing list