[Tutor] OT: "Your tests are only as good as your mocks." Comments?

Peter Otten __peter__ at web.de
Sun Jul 25 18:17:18 EDT 2021


On 25/07/2021 19:14, boB Stepp wrote:
> From
> https://swizec.com/blog/what-i-learned-from-software-engineering-at-google/#stubs-and-mocks-make-bad-tests 
> 
> 
> The author of this article notes an example from his practice where his 
> mock
> database that he used in his tests passed his tests when the actual code in
> production no longer had a database column that was in his mock 
> database.  As
> I have begun to play around with databases recently and how to test code
> relying on them, this really caught my attention.
> 
> The overall article itself is a recap of what he read in a book about how
> Google does things ("Software Engineering at Google").  In this situation
> Google advocates for using "fakes" in place of mocks, where these fakes are
> simplified implementations of the real thing maintained by the same team to
> ensure API parity.  How would the development and maintaining of these 
> fakes
> be done so that the fakes don't drift from coding reality like the mocks
> might?  It is not clear to me exactly what is going on here.  And a more
> Python-specific question:  Does the Python ecosystem provide tools for
> creating and managing fakes?

Bob, my observation is that you have a penchant to attack simple 
problems in the most complex way that exists.

You are not Google! All your teams are likely just you;)

You have a sqlite database of a few Megabytes -- or is it Kilobytes?
You can easily copy the "real thing" into your test environment and run 
a few tests with it, and also compare the database layout with that of a 
smaller test db that contains hand-crafted data for your other tests.

To increase the off-topicity a bit, here's a link which IIRC I first saw 
on comp.lang.python a few  -- tempus fugit -- years ago.

https://www.theonion.com/beaver-overthinking-dam-1819568416

Have fun!




More information about the Tutor mailing list