[TIP] Unit testing functions which call super
Marcin.Tustin at dealertrack.com
Wed Aug 13 13:15:49 PDT 2014
Yes: the reason is that I’m not writing an integration test, I’m writing a test to test this specific method. We need unit tests to test our individual units, and integration tests to test them together. It’s not wise to rely only on integration tests (nor only on unit tests).
I actually do share the concern about over mocking (it’s easy to mock so much that you test nothing), but it’s important not to throw the baby out with the bathwater. Integration tests by their nature lack granularity to pinpoint problems (and yes, I realize it’s possible and desirable to set up integration tests so that do point to where a detected problem originates, but it’s still not a substitute for appropriate unit testing).
From: David Stanek [mailto:dstanek at dstanek.com]
Sent: Wednesday, August 13, 2014 2:35 PM
To: Marcin Tustin
Cc: testing-in-python at lists.idyll.org
Subject: Re: [TIP] Unit testing functions which call super
On Wed, Aug 13, 2014 at 2:00 PM, Marcin Tustin <Marcin.Tustin at dealertrack.com<mailto:Marcin.Tustin at dealertrack.com>> wrote:
I’ve come across a method which I needed to add a unit test for, which calls super, e.g.
Is there any reason you can't call the parent's super? In my view of testing you want to create an object, feed it input, and then check the output/side effect. I would stay away from mocking internals like this.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the testing-in-python