Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #4418

Re: skipping one unittest assertion?

From Ben Finney <ben+python@benfinney.id.au>
Newsgroups comp.lang.python
Subject Re: skipping one unittest assertion?
References <roy-880487.10134901052011@news.panix.com> <87wriah4qg.fsf@benfinney.id.au> <roy-1458D0.11552901052011@news.panix.com>
Date 2011-05-02 07:45 +1000
Message-ID <87k4eagknd.fsf@benfinney.id.au> (permalink)
Organization Unlimited download news at news.astraweb.com

Show all headers | View raw


Roy Smith <roy@panix.com> writes:

>  Ben Finney <ben+python@benfinney.id.au> wrote:
>
> > Each test case should be testing one thing: if it fails, it should be
> > for exactly one reason.
>
> Well, yeah, that's certainly the XP/unit-test doctrine. In practice
> however, tests often get written as "do a bunch of stuff to get some
> result, then make a bunch of assertions about that result".

And the result is an increasingly-difficult maintenance burden for the
test suite, as you've discovered.

> Sure, you could make each of those assertions a distinct method, and 
> factor the "do a bunch of stuff" into setUp().  Which probably means 
> factoring those methods out into a new TestCase subclass.  At some 
> point, however practicality trumps doctrine.

Yet practicality, i.e. making your test cases manageable, is exactly
what you don't have with your current approach. I'm not quoting doctrine
at you; I'm saying that *because of problems like you're encountering*,
you should refactor your test cases to do one test per case.

-- 
 \        “Absurdity, n. A statement or belief manifestly inconsistent |
  `\            with one's own opinion.” —Ambrose Bierce, _The Devil's |
_o__)                                                Dictionary_, 1906 |
Ben Finney

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

skipping one unittest assertion? Roy Smith <roy@panix.com> - 2011-05-01 10:13 -0400
  Re: skipping one unittest assertion? Ben Finney <ben+python@benfinney.id.au> - 2011-05-02 00:31 +1000
    Re: skipping one unittest assertion? Roy Smith <roy@panix.com> - 2011-05-01 11:55 -0400
      Re: skipping one unittest assertion? Ben Finney <ben+python@benfinney.id.au> - 2011-05-02 07:45 +1000
  Re: skipping one unittest assertion? "OKB (not okblacke)" <brenNOSPAMbarn@NObrenSPAMbarn.net> - 2011-05-01 18:14 +0000
    Re: skipping one unittest assertion? Roy Smith <roy@panix.com> - 2011-05-01 14:16 -0400
      Re: skipping one unittest assertion? Chris Angelico <rosuav@gmail.com> - 2011-05-02 06:51 +1000

csiph-web