Re: Single assert / Single mock rule in practice
Mateusz Łoskot <[email protected]> Tue, 14 Jan 2014 16:18:00 +0000
| Newsgroups | gmane.comp.programming.test-driven-development |
|---|---|
| Message-ID | <CABUeae8GSD85_Mxx71DjvSovnsJk859OSm-MeDBwj+r0wvCnPQ@mail.gmail.com> |
On 14 January 2014 12:05, Mateusz Łoskot <[email protected]> wrote: > 2) What about having both assertions, would that break the single > assertion rule? > > self.assertTrue(item_exists) > foo.xdep.get_item.assert_called_once_with(1) > [...] > 3) AFAIU, it's natural that unit tests are coupled with implementation of > method/behaviour they are testing, foo.exists function in my case. > [...] I'm re-reading my own post and realising, aren't 2) and 3) breaking the guideline [1] about writing tests to the interface, not the implementation? I think the original version of test_exists_ExistingItemId_ReturnTrue I've got is written to the interface and mocks only bare minimum of required dependencies. Anyone could help me out to get in order with terminology vs practice vs best practices here? How much unit tests should know about implementation of what is being tested? [1] "Stop Mocking, Start Testing" Augie Fackler and Nathaniel Manista at Google http://youtu.be/Xu5EhKVZdV8?t=18m9s Best regards, -- Mateusz Łoskot, http://mateusz.loskot.net