Unit Tests & Integration Tests
Gustavo Niemeyer
gustavo at niemeyer.net
Fri Sep 12 14:45:17 UTC 2014
On Fri, Sep 12, 2014 at 7:42 AM, Michael Foord
<michael.foord at canonical.com> wrote:
> I agree. I tend to see the need for stubs (I dislike Martin Fowler's
> terminology and prefer the term mock - as it really is by common parlance
> just a mock object) as a failure of the code. Just sometimes a necessary
> failure.
I don't particularly mind either way. It's a bit like a game.. we can
make our own rules, as long as we're playing by the same rules.
> Code, as you say, should be written as much as possible in decoupled units
> that can be tested in isolation. This is why test first is helpful, because
> it makes you think about "how am I going to test this unit" before your
> write it - and you're less likely to code in hard to test dependencies.
That's a good way to put it.
> Where dependencies are impossible to avoid, typically at the boundaries of
> layers, stubs can be useful to isolate units - but the need for them often
> indicates excessive coupling.
Indeed.
> Being able to test business logic without having to start a state server and
> mongo will make our tests soooo much faster and more reliable. The more we
> can do this *without* stubs the better, but I'm sure that's not entirely
> possible.
The tests will definitely be much faster and more reliable. The only
point to consider is whether the implementation will also be faster
and more reliable. I'm sure you all can do the latter.. just something
to keep in mind.
gustavo @ http://niemeyer.net
More information about the Juju-dev
mailing list