Vous êtes sur la page 1sur 4

The Business of Software Phillip G.

Armour

The Unconscious Art of


Software Testing
The subtle psychology of testing.

I
n The Art of Software Testing, constructed intellectual models. have found out earlier but didn’t
Glenford Myers asserted that It is not possible to be wholly due to some negligence on our
“…the most important con- deterministic about testing since part. However, exposing things we
siderations in software testing we don’t know what to be deter- didn’t know we didn’t know by
are issues of economics and ministic about. Testing, probably dynamically executing the knowl-
human psychology” [6]. In fact, more than any other activity in edge contained in a system is not
the most important considera- itself a bad thing. We’ve stopped
tions of any software development punishing testers for finding
practice are (or should be) issues defects, though rewarding them
of economics and human psy- for the same has its perils.
chology. Particularly psychology. Sometimes the most effective
The challenge in testing sys- and efficient way to find certain
tems is that testers are trying defects is to test for them. This
to develop a way to find out does not in any way substitute
if they don’t know that they for good engineering practices
don’t know something. This and feedback mechanisms such
is equivalent to a group of as inspections. Indeed, without
scientists trying to devise an such processes in place and
experiment to reveal something working, any attempt at dynamic
they are not looking for. It is testing quickly becomes over-
extremely difficult to do. In fact, whelmed and quite ineffective. But
as Thomas Kuhn pointed out, the there are certain kinds of problems
image we have of the scientist that are very difficult to identify
boldly going into uncharted terri- analytically. Some companies I
tory and finding out things we software development, is about work with perform enormous
never knew is at odds with the discovery. In the bad old days, quantities of integration testing.
reality [5]. Scientists almost always people were sometimes punished They must do this because they
find out things they already know. for finding defects, since defects have enormously integrated sys-
The hypothesis must come before were considered bad. In my previ- tems and it is very difficult to
the experiment to confirm (or ous column, I pointed out that determine their behavior in opera-
deny) it. In fact, it is almost rou- even the word “defect” is a little, tion unless you execute them in
tine for scientists to ignore results well, defective [2]. By the time we some controlled fashion. Simula-
PETER HOEY

that get in the way of their pre- get around to dynamic testing tion is taking over traditional test-
conceived notions and carefully there may be things we should ing in some of these areas, but a

COMMUNICATIONS OF THE ACM January 2005/Vol. 48, No. 1 15


The Business of Software

close look at what is actually done 10% of our brains. This is not driving a car, and found that you
in an executable simulation shows true. While some physical parts have driven, accident-free, all the
it is not unlike testing in the way it of our brains may be more elec- way to your destination but were
is set up and run. In fact, I think trochemically active than others quite (consciously) unaware of
the boundaries between a “real” at different times, parts of our performing the activities involved
system and a simulator and the brains do not simply shut down. in driving? Obviously when we do
execution of “tests” against the real All of our brain is active all of this we are not unconscious in the
system and the execution of a sim- the time. The conscious inten- sense of being in a coma, other-
ulation will become progressively tional introspective part of the wise the journey would not have
blurred. In both cases the real and brain, however, has (and needs) been accident-free. The complex
the simulation system will repre- only limited access to what is process of navigating, steering, and
sent some subset of the necessary going on. It would be extremely avoiding accidents was all the way
knowledge that has been made tedious to require our brains to down there with the pancreatic
executable, which is what, of consciously process, say, our pan- function. There is an enormous
course, software is anyway. creatic function in order to make amount of processing that occurs
it work. What we call “conscious- inside our skulls of which we are
Testing vs. Inspections? ness” is a very small part of what quite unaware at an intentional

T
here is no doubt that is going on inside our heads. Our level. And this capability can be
inspections can be very consciousness is that part of our leveraged. Bertrand Russell, the
effective and must be brain function that is self-aware. English mathematician and
used if we wish to obtain This capability is inherent to philosopher, asserted he never
high-quality software. But being human, and there is evi- attempted to consciously solve a
despite evidence of the “superior- dence that it differentiates us math problem. He would read
ity” of inspections and other from other animals. In fact, it is about it, absorb as much informa-
quality assurance devices over reflected in the very name of the tion as he could, and then go to
dynamic testing, luckily we don’t human race. The Latin label for sleep. On awakening, he usually
have to choose between them. the current version of the human found he had the answer figured
We can have and we need both race is not Homo Sapiens as is out. Brains can do that.
effective inspections and effective often cited—it is Homo Sapiens So what does this have to do
testing. No matter how good we Sapiens. This means almost liter- with software testing?
get at managing other aspects of ally “man who thinks about
development, it is not likely that thinking” (or perhaps man who Testing Strategies
execution of software systems thinks twice?). Much of what passes for method
under controlled conditions for Other animals undoubtedly in testing involves heuristic
the purpose of determining their think, but they don’t appear to strategies. We selectively test
validity will disappear in the near think about thinking as an activ- complex predicate logic, we cre-
future. So, given that testing is ity. They don’t introspect. The ate test cases that span the classes
probably here to stay, how do we most obvious and well-known of inputs and outputs, we con-
create tests for things of which type of thought is this conscious struct combinations of condi-
we are unaware? intentional kind, but there are tions, we press the system to its
other kinds and other levels. Have boundaries both internally and
10% of Your Brain you ever puzzled over a problem, externally, we devise weird com-
It has been said that we only use or wrestled with a worry while binations of situations that might

16 January 2005/Vol. 48, No. 1 COMMUNICATIONS OF THE ACM


Testing, probably more than any other activity in
software development, is about discovery.
never occur in the real world, but being subject to this limitation, They experience a kind of intu-
which we think might expose a usually has no difficulty in quite ition that tells them what to test
so-far unknown limitation in the publicly demonstrating our lack of and how. A simple example of this
system. None of these are guaran- knowledge. in operation can be shown in the
teed to throw a defect. In fact, The second hypothesis demon- layering or sequencing of tests. At
nothing in testing is guaranteed, strates the paradox of testing: if I the beginning of The Art of Soft-
since we don’t really know what have sufficient knowledge about ware Testing, Myers suggests a self-
we are looking for. We are just what is wrong with my system I test to determine your test
looking for something that tells can create a robust set of test cases effectiveness (his phrase). It
us we don’t know something. and results that will show if there is involves establishing a set of tests
Often this is obvious, as when the anything I don’t know. But if I do for a trivial program that accepts
system crashes; sometimes it is have sufficient knowledge about inputs to be used to predict
quite subtle. what I don’t know, I must a priori whether the values, if numeric,
know it, which means I have will describe the sides of an equi-
The Dual Hypotheses of already exposed my ignorance and lateral, an isosceles, or a scalene
Knowledge Discovery therefore I don’t need to test at all. triangle. Presumably, the program
The Dual Hypotheses of Knowl- Testing, it seems, is effective only if will also indicate if the input val-
edge Discovery [3] are: we don’t need to do it, and is not ues cannot make a triangle at all
very effective when we do need to for some reason. A standard (cor-
• We can only discover knowl- do it. rect or valid) input test case might
edge in an environment that be to use the numbers 3, 4, and 5.
contains that knowledge. Paradoctoring the Paradox These numbers, representing the
• The only way to assert the How can we effectively address lengths of the sides of a triangle,
validity of any knowledge is to this situation? Our testing heuris- would produce a right-angled sca-
compare it to another source of tics of boundary value analysis lene triangle. Assuming the pro-
knowledge. and equivalence partitioning help. gram works well for this input,
They point us to the locations of would it be better to next execute

T
he first hypothesis shows high-density knowledge within a test for the number set 3, 5, 4?
us why, sometimes, we our system. We are most likely to Or how about the number set 4,
cannot test for and detect make mistakes where complex 5, 6 or 6, 4, 5?
defects in the lab. If we knowledge is clustered. Where

A
cannot duplicate, in sufficient things are complicated we usually s shown in the table
detail and with sufficient control, understand them less and our here, the choices in this
the situations that will occur in ignorance (read defects) is usually case are between chang-
the customer’s environment when higher. ing only the order of the
we release the software, we cannot But there is another aspect to inputs, only their values or
expose these defects. Of course, consider. I have found good changing both order and value at
the customer’s environment, not testers have a “nose” for testing. the same time. Is it “better” to

COMMUNICATIONS OF THE ACM January 2005/Vol. 48, No. 1 17


The Business of Software

Nothing in testing is guaranteed, since we don’t really know what we are


looking for. We are just looking for something that tells us we don’t
know something.
change fewer variables (3,4,5 –> how, where, and how much to Dig Deep
3,5,4 or 3,4,5 –> 4,5,6) and if so, test. The logic behind it can be In the preface to the first chapter of
would changing the value or the difficult to explain, though we can The Timeless Way of Building,
order be more effective at expos- usually rationalize a decision even Christopher Alexander said (of
ing something we don’t know if we don’t know exactly how or architecture) “It is a process which
about the program? Or would it why we made it. Below the con- brings order out of nothing but
be better to change more vari- scious, intentional part of reason- ourselves” [1]. He states that people
ables (3,4,5 –> 6,4,5)? The ing, there’s a lot going on, and have an intuitive sense of what is
answer is—it depends. Good good testers are able to pick up on right, orderly, and effective. This
testers, as they acquire confi- sense is not particularly logical,
Input Test 1 Test 2a Test 2b Test 2c
dence in the predictability of the intentional, or easy to understand,
A 3 3 4 6
system being tested, will gradu- but it is there. Good testers are able
B 4 5 5 4
ally increase the number of C 5 4 6 5
to employ an intuitive reasoning
changed variables. Increasing the process that is not easy to explain
variation too soon may flush out Choosing between changing input order, or codify. The same is true of many
input value, or both.
a defect, but make it very diffi- creative aspects of what people do.
cult to find out what caused it to The psychology of testing is both
throw. Increasing the variation little hints that direct their testing interesting and “the most impor-
too slowly results in many more approach through a below con- tant consideration.”
tests, each with an associated scious reasoning process. Sometimes we don’t quite know
effort. Maybe a hint of remembered how it works, but it works. c
While this example is quite experience of a similar system, a
trivial and we could easily test all dash of knowledge of the customer, References
combinations in a short while, a pinch of uneasiness about the 1. Alexander, C. The Timeless Way of Building.
Oxford University Press, 1979.
this is not true for larger systems rushed design phase, and a dollop 2. Armour, P.G. Not-Defect: The mature discipline
and the rate of test scaling can be of knowledge of the capabilities of of testing. Commun. ACM 47, 10 (Oct. 2004).
3. Armour, P.G. The Laws of Software Process.
critical. Testing systems is always the developers overlay the testing Auerbach Publishers, 2003.
sample testing. We can only run heuristics good testers have acquired 4. DeMarco, T. and Lister, T. Peopleware.
an infinitesimal percentage of the and lead to a sure sense of what will Dorset House Publishing, 1987.
5. Kuhn, T.S. The Structure of Scientific Revolu-
total possible tests. We must make this system break and expose tions. University of Chicago Press, 1970.
somehow extrapolate from the our lack of knowledge. Tom 6. Myers, G.J. The Art of Software Testing.
Wiley, New York, 1979.
behavior of this tiny sample to DeMarco and Tim Lister devoted
the behavior of the enormous an entire (but very brief) chapter of Phillip G. Armour
whole. Knowing when and how their book Peopleware to a leg- (armour@corvusintl.com) is a senior consultant
to scale up testing is crucial to endary team of testers for an anony- at Corvus International Inc., Deer Park, IL and a
research director in the Center for Software
good testing. Good testers know mous but large computer company Development Innovation at Number Six Soft-
how to do this. located in upstate New York that ware, Arlington, VA.
I have found that good testers seemed to have this skill [4]—it is
get a kind of intuitive sense of very valuable. © 2005 ACM 0001-0782/05/0100 $5.00

18 January 2005/Vol. 48, No. 1 COMMUNICATIONS OF THE ACM

Vous aimerez peut-être aussi