[MERGE] inode sorted stats in status

Andrew Bennetts andrew at canonical.com
Tue Sep 2 04:23:39 BST 2008


Robert Collins wrote:
> On Tue, 2008-09-02 at 12:32 +1000, Andrew Bennetts wrote:
> > 
> > If statements in test methods are a bad smell.
> 
> Are they? I think its entirely appropriate when an interface can
> optionally do something that the test matches that optional capability.
> 
> Trying to avoid that makes the test not fit the code (and vice versa)
> and _that_ is a bad smell.

(Replying just for the benefit of the list, this has been discussed thoroughly
on the IRC channel.)

As discussed on IRC, I should perhaps have said “can be a bad smell”.  Tests
with conditional statements in them can be unclear, and specifically this one
was.

Robert asked on IRC where the "if in tests is bad" meme comes from.  Probably
the xUnit Test Patterns book has made it popular.  It lists Conditional Test
Logic as a test smell:
<http://xunitpatterns.com/Conditional%20Test%20Logic.html>.

My view — which matters because I review code ;) — is that conditional logic in
tests can make the test more complex than a good test should be, but doesn't
automatically doom the test.  Use common sense to judge if a test is clear
enough, not checklists of test smells.

-Andrew.




More information about the bazaar mailing list