Three distinct testing topics usually muddled together: 1. Categories (unit, integration) 2. Mechanics (mocks, assertions) 3. Motivation
-
-
Crucially: the portfolio of tests you write changes depending on which of these are most important. Different _mechanics_ come into play.
-
Which reasons are most important to you, in turn, are different in different places in the codebase, and also shift over time.
-
When people make statements about test mechanics ("don't use mocks!"), they're really just telling you how they order that list of reasons.
-
I want more discussions of how various mechanics enable or restrict tests from fulfilling those basic reasons, and fewer blanket statements.
-
This is NOT a list of what you always get. They're possible outcomes, and you can write tests differently to emphasize different ones.
-
Imagine a set of tests written with only one goal in mind: preventing regressions. What does that look like?
-
When I see a codebase primarily covered with top-level integration tests, I know that team sees regression catching as testing's only goal.
-
Now imagine a set of tests written with the express goal of enabling later refactoring. That looks quite different.
- Show more
-
-
-
@sarahmei also, #4 doesn't ring true for me. Speaking as an ardent long term TDDist I think we always wanted this to be true but it ain't. -
@ph1 it's possible to write tests that add nothing to your understanding. It's also possible to write tests that illuminate dark corners. -
@ph1 These aren't a list of what you always get; they're possible outcomes, and you can write tests differently to emphasize different ones. -
@sarahmei ah. An interesting lens to look at them through.
-
-
-
@sarahmei@grmpyprogrammer don't forget because they feel pressured to do so by just about any programming blogger ;) -
.
@SPengilley@sarahmei@grmpyprogrammer if you feel externally pressured to do tests, you haven't been programming long enough. :) -
@dkarlovi@SPengilley@grmpyprogrammer external pressure can be an opportunity to talk with the source about their underlying reasons.
-
-
-
@sarahmei I'd perhaps replace 1 with a more general "validate behavior". I usually first write tests to verify things actually work. -
@ph1 Hmm, you're right - this list is more the lasting effects of writing a test. Maybe there's another list of more immediate benefits. -
@sarahmei not sure it's worth distinguishing - all I can see in the immediate list is "correct" and "good design". Maybe faster feedback?
-
-
-
@sarahmei I'd add 5) Improve understanding of the problem -
@mike_bowler I'd say that's a better way to word #2. :) -
@sarahmei Calling out design separately still makes sense to me :-)
-
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.
Sarah Mei
Pete Hodgson
Stephen Pengilley
Dalibor Karlović
Mike Bowler