unit testing

Steve Howell showell30 at yahoo.com
Sun May 27 19:32:45 EDT 2007


Let me preface every reply here by YMMV.  I strongly,
strongly encourage people to tap into the unit testing
community for all tools that are available to them.

Also, let me say that despite any place where Steven
and I disagree about the mechanics of unit testing,
we're in firm agreement that UNIT TESTING IS
IMPORTANT.  And sorry for shouting.  And, really, if
you're not doing automated tests on your application
now, you don't know what you're missing.


--- Steven Bethard <steven.bethard at gmail.com> wrote:
> 
> >    1) For flat-out failures, we just fail with a
> > traceback right away.
> 
> Looks like that's the -x/--exitfirst option in
> py.test.
> 

Yes, but for my purposes, it's even easier to do
absolutely nothing when a test fails, just let it pass
through.


> >    2) We don't use assertions very often, but
> rather
> > just diff the output files to the GOLD files. 
> This
> > may eventually stop to scale, but it hasn't yet.
> 
> I guess I don't do enough stuff with file input and
> file output for this 
> to make sense for me.
> 

First, I should say that we don't completely ignore
assertion tests, as it's useful for testing truly
functional code, such as something that simply parses
a message.  

But most of our application is I/O driven, and the
actual tricky modules of our application do manage a
conversation between a terminal and a host, and it's
that conversation between the terminal that we want to
proceed in a predictable fashion.


> >   4) We have quite a few mock-ish objects, mainly
> > relating to simulating I/O situations.
> 
> 
> You might look into the Python Mock module:
> 
>      http://python-mock.sourceforge.net/
> 

Again, this is a case, where pardon my arrogance, I
already know how my objects work, so I already know
how to emulate them.  I've read up on mock objects, so
I'm not totally ignoring common wisdom, it's just that
I get it, have a powerful language at my disposal,
etc.  I fully concede that my mock objects might be
missing key features from the Python Mock module, but
I also assert that I can implement pretty robust unit
testing without it.








       
____________________________________________________________________________________Got a little couch potato? 
Check out fun summer activities for kids.
http://search.yahoo.com/search?fr=oni_on_mail&p=summer+activities+for+kids&cs=bz 



More information about the Python-list mailing list