On Fri, Feb 13, 2015 at 6:50 PM, Eric Snow <eric.s...@canonical.com> wrote: > Using a fake for that input means you don't have to encode the > low-level business logic in each test (just any setup of the fake's > state). You can be confident about the low-level behavior during > tests as matching production operation (as long as the fake > implementation is correct and bug free). The potential downsides are > any performance costs of using the fake, maintaining the fake (if > applicable), and knowing how to manage the fake's state. > Consequently, there should be a mechanism to ensure that the fake's > behavior matches the real thing.
All of these costs exist whether you are dealing with one fake implementation, or with logic spread through five hundred tests which all include details of that interface. Hopefully the saner approach is obvious. > Alternately you can use a "stub" (what I was calling a fake) for that > input. On the upside, stubs are lightweight, both performance-wise > and in terms of engineer time. They also help limit the scope of what > executes to just the code in the function under test. The downside is > that each test must encode the relevant business logic (mapping > low-level inputs to low-level outputs) into the test's setup. Not > only is that fragile but the low-level return values will probably not > have a lot of context where they appear in the test setup code > (without comments). Precisely. And that also implies the test knows exactly how the function is using the interface, thus leaking its implementation into the test, and preventing the implementation to change even in simple ways without breaking the test. >> I'd be very careful to not overdo this. Covering a line just for the >> fun of seeing the CPU passing there is irrelevant. If you fake every >> single thing around it with no care, you'll have a CPU pointer jumping >> in and out of it, without any relevant achievement. > > I was talking about branches in the source code, not actual CPU branch > operations. :) Oh, so you mean you are not testing all CPU branches!? (/me provokes the inner perfectionist spirit ;-) gustavo @ http://niemeyer.net -- Juju-dev mailing list Juju-dev@lists.ubuntu.com Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/juju-dev