Software Specs Flashcards
Key observations
First, program specifications have to be made explicit, or else there cannot be
effective communication between those implementing code and those testing it.
Second, development and testing of a program are often done independently. This
helps to ensure that errors in the code are caught.
Third, there are only finitely many resources available to development teams; not
every bug can be found and caught.
Fourth, program specifications are not static; they evolve over time, and programming
teams need to be able to adapt to these changes.
Classifications of testing
Manual, automated, black-box, white-box
Black-box testing
Black-box testing refers to testing where the tester can see nothing about the tested
program’s internal mechanisms: as though the program is contained inside an opaque
box. The tester can only issue inputs to the program, observe the program’s outputs,
and determine whether they meet the specifications required of the program.
White-box testing
White-box testing refers to testing in which the internal details of the program being
tested are fully available to the tester. The tester can use these internal details to
perform a more precise analysis of the tested program and uncover inputs that are
more likely to trigger buggy behavior.
advantages of automated testing
we can
potentially spot bugs more quickly through the speed advantage of a computer over a
human in issuing inputs and checking outputs. Additionally, there is no need to write
tests: they are generated by the computer itself. Moreover, if the software changes,
there is no need to update the tests by hand, as the computer will generate new tests
relevant to the updated software.
advantages of manual testing is
humans are potentially
better able to select an efficient set of tests: computer-generated test suites can be
rather bloated. Additionally, humans can potentially construct a test suite with better code coverage than a computer program could, though this is not guaranteed.
semi-automated approach
combination of automated and manual
advantages of Black-box testing
First, it does not
require modifying the code, that is, introducing probes into the code.
Second, does not need to study the code to be tested.
Third, can be performed on any format of code, whether it is
managed code, binary code, obfuscated code, etc.
advantages of white-box testing
the tester is potentially able to construct a more
efficient suite of test cases with potentially better coverage than black-box testing
could.
constraints that prevent us from making testing entirely automatic
testing is a hard enough problem even for a small piece of code.
And if
a program has a loop, there could potentially be an infinite number of routes through
the code, in which case it becomes impossible to test the code under all possible
conditions.
And if we don’t have a specification for our program, then no testing can be done at
all
Safety properties
state that something bad will never happen, for example, an
assertion violation. We will momentarily look at other forms of safety properties such
as types and type-state properties.
liveness properties state
something good will eventually happen.
Examples of liveness properties include program termination and starvation freedom.
Starvation refers to a problem in scheduling algorithms wherein a process is
perpetually denied necessary resources to process its work.
Type-state properties
another form of safety properties. They extend types to
capture temporal properties of objects. For instance, the program must not read from
an object of type java.net.Socket until it is connected.
Assertions
general form of safety properties that allow the programmer to
specify that a certain predicate must always hold at a certain point in the program.
Assertions can be implicit such as checking that a variable P is not null before
dereferencing it each time in a managed language like Java. They can also be explicit,
for example, when checking whether a variable Z equals 42 at a certain point in the
program.
Pre and Post conditions
further generalize assertions. Pre-conditions must be true
before a statement or a method while post-conditions must be true after the statement
or method is complete.