Beruflich Dokumente
Kultur Dokumente
For a while now, somethings felt strange to me about the way that
automated tests are often marketed to the development community.
For one, I think the term test itself is quite misleading. It conjures up
this idea that weve found a viable replacement to manual testing; that
if all tests passwe are guaranteed bug-free software. But,
automated tests arent really testing a system at-large, so much as
they are checking specific behavior within a system.
For example, suppose I want to test out the security around our
billing page. I could write a couple of integration tests, by using a tool
like Selenium, to confirm the following assumptions:
The same is true for unit tests. While they test very narrow and well-
defined functionality, they arent going to test for, as Uncle Bob states,
the stuff out at the boundaries of the system. Also, with unit tests,
there is often the talk of 100% code coverage. James O Coplien
argues that its pragmatically impossible to achieve if we define this
as:
So, where does this get us? I often visualize automated tests like
building a frame (the tests we write) around a constantly morphing
structure (the true behavior we want). We can nail lots of posts
together to build a frame that begins to resemble the behavior we
want, but well never quite get there.
Writing automated tests provide basic boundaries for bug-free code, but are by no means an
end-all solution.
So, whats the big deal about calling a check a test? When we start
becoming overly confident in our ability to write bug-free code simply
based on a successful series of automated tests, the returns begin to
diminishrapidly. Our minds start to let go of some of the natural
deliberateness we may have once put into code prior to the feeble
safety net of automated tests. At its worst, it means we become
narrowly-focused developers, using one relatively brittle measure of
success as false justification that our testing is now complete.
The real question we should ask is, how do we pragmatically make the
introduction of bugs as improbable as possible, (while weighing all the
other important matters of software, like new features, deadlines,
etc.)? To me, it starts with the right programmer mentality.
Here are five cases to test with every kind of object you manage
in your system.
Heres a more general approach to thinking through your
checking scenarios.
Finally, a general heuristic for tackling mysterious bugs.
Originally published Apr 28, 2015 at DoneDone. Go to the next essay in Testing, Cut the
problem in half.
Tweet Share
Other categories
Business & Work
Coding
Design
Teaching
Testing
Miscellaneous