Lesson 8 Testing
Lesson 8 Testing
CERTIFICATE IN SOFTWARE
DEVELOPMENT
The first goal leads to validation testing, where you expect the
system to perform correctly using a given set of test cases that
reflect the system’s expected use.
The second goal leads to defect testing, where the test cases are
designed to expose defects.
The test cases in defect testing can be deliberately obscure and
need not reflect how the system is normally used.
SOFTWARE VERIFICATION AND
VALIDATION
Testing is part of a broader process of software verification and validation (V
& V).
1. Validation: Are we building the right product?
2. Verification: Are we building the product right?
Verification and validation processes are concerned with checking that
software being developed meets its specification and delivers the functionality
expected by the people paying for the software.
The aim of verification is to check that the software meets its stated functional
and non-functional requirements.
Validation, however, is a more general process. The aim of validation is to
ensure that the software meets the customer’s expectations. It goes beyond
simply checking conformance with the specification to demonstrating that the
software does what the customer expects it to do.
Validation is essential because, requirements specifications do not always
reflect the real wishes or needs of system customers and users.
ULTIMATE GOAL OF VERIFICATION AND VALIDATION
1. During testing, errors can mask (hide) other errors. When an error leads to
unexpected outputs, you can never be sure if later output anomalies are due to a
new error or are side effects of the original error. Because inspection is a static
process, you don’t have to be concerned with interactions between errors.
Consequently, a single inspection session can discover many errors in a system.
2. Incomplete versions of a system can be inspected without additional costs. If a
program is incomplete, then you need to develop specialized test harnesses to test
the parts that are available. This obviously adds to the system development costs.
3. As well as searching for program defects, an inspection can also consider broader
quality attributes of a program, such as compliance with standards, portability, and
maintainability. You can look for inefficiencies, inappropriate algorithms, and poor
programming style that could make the system difficult to maintain and update.
Typically, a commercialSTAGES OF TESTING
software system has to go through three stages of
testing:
1. Development testing, where the system is tested during
development to discover bugs and defects. System designers and
programmers are likely to be involved in the testing process.
2. Release testing, where a separate testing team tests a complete
version of the system before it is released to users. The aim of release
testing is to check that the system meets the requirements of system
stakeholders.
3. User testing, where users or potential users of a system test the
system in their own environment. For software products, the ‘user’ may
be an internal marketing group who decide if the software can be
marketed, released, and sold. Acceptance testing is one type of user
testing where the customer formally tests a system to decide if it
should be accepted from the system supplier or if further development
1. DEVELOPMENT TESTING
Development testing includes all testing activities that are carried
out by the team developing the system.
The tester of the software is usually the programmer who developed
that software, although this is not always the case.
Some development processes use programmer/tester pairs where
each programmer has an associated tester who develops tests and
assists with the testing process.
For critical systems, a more formal process may be used, with a
separate testing group within the development team.
They are responsible for developing tests and maintaining detailed
records of test results.
DEVELOPMENT TESTING LEVELS
Two possible strategies that can be effective in choosing test cases are:
1. Partition testing, where you identify groups of inputs that have
common characteristics and should be processed in the same way. You
should choose tests from within each of these groups.
2. Guideline-based testing, where you use testing guidelines to choose
test cases. These guidelines reflect previous experience of the kinds of
errors that programmers often make when developing components.
PARTITION TESTING
The input data and output results of a program often fall into a number of
different classes with common characteristics. Examples of these classes are
positive numbers, negative numbers, and menu selections.
Programs normally behave in a comparable way for all members of a class.
That is, if you test a program that does a computation and requires two
positive numbers, then you would expect the program to behave in the same
way for all positive numbers.
Because of this equivalent behavior, these classes are sometimes called
equivalence partitions or domains.
One systematic approach to test case design is based on identifying all input
and output partitions for a system or component.
Test cases are designed so that the inputs or outputs lie within these partitions.
PARTITION TESTING
Partition testing can be used to design test cases for both systems and
components.
Once you have identified a set of partitions, you choose test cases from
each of these partitions.
A good rule of thumb for test case selection is to choose test cases on the
boundaries of the partitions, plus cases close to the midpoint of the
partition.
The reason for this is that designers and programmers tend to consider
typical values of inputs when developing a system. You test these by
choosing the midpoint of the partition.
Boundary values are often atypical (e.g., zero may behave differently from
other non-negative numbers) so are sometimes overlooked by developers.
Program failures often occur when processing these atypical values.
EQUIVALENCE PARTITIONING
When you use the specification of a system to identify equivalence
partitions, this is called ‘black-box testing’. Here, you don’t need
any knowledge of how the system works.
However, it may be helpful to supplement the black-box tests with
‘white-box testing’, where you look at the code of the program to
find other possible tests.
For example, your code may include exceptions to handle incorrect
inputs. You can use this knowledge to identify ‘exception
partitions’—different ranges where the same exception handling
should be applied.
Equivalence partitioning is an effective approach to testing because
it helps account for errors that programmers often make when
processing inputs at the edges of partitions.
TESTING GUIDELINES
Guidelines encapsulate knowledge of what kinds of test cases are effective for
discovering errors. For example, when you are testing programs with
sequences, arrays, or lists, guidelines that could help reveal defects include:
1. Test software with sequences that have only a single value. Programmers
naturally think of sequences as made up of several values and sometimes
they embed this assumption in their programs. Consequently, if presented
with a single value sequence, a program may not work properly.
2. Use different sequences of different sizes in different tests. This decreases
the chances that a program with defects will accidentally produce a correct
output because of some accidental characteristics of the input.
3. Derive tests so that the first, middle, and last elements of the sequence are
accessed. This approach is reveals problems at partition boundaries.
GENERAL GUIDELINES
1. Choose inputs that force the system to generate all error messages;
2. Design inputs that cause input buffers to overflow;
3. Repeat the same input or series of inputs numerous times;
4. Force invalid outputs to be generated;
5. Force computation results to be too large or too small.
As you gain experience with testing, you can develop your own
guidelines about how to choose effective test cases
BLACK BOX (FUNCTIONAL) TESTING
This type of testing is termed black box testing because no knowledge of the workings of
the program is used as part of the testing – we only consider inputs and outputs. The
program is thought of as being enclosed within a black box.
We then run the program, input the data and see what happens.
Black box testing is also known as functional testing because it use only knowledge of the
function of the program (not how it works).
Ideally, testing proceeds by writing down the test data and the expected outcome of the
test before testing takes place. This is called a test specification or schedule.
Then you run the program, input the data and examine the outputs for discrepancies
between the predicted outcome and the actual outcome.
Test data should also check whether exceptions are handled by the program in accordance
with its specification.
BLACK BOX (FUNCTIONAL) TESTING
Consider a program that decides whether a person can vote, depending on
their age. The minimum voting age is 18.
We cannot realistically test this program with all possible values, but
instead we need some typical values.
The approach to devising test data for black box testing is to use
equivalence partitioning.
This means looking at the nature of the input data to identify common
features.
In the voting program, we recognize that the input data falls into two
partitions:
1. the numbers less than 18
2. the numbers greater than or equal to 18
BLACK BOX (FUNCTIONAL) TESTING
0 18
17 infinity
We run the program with the following sets of data and note any discrepancies between
predicted and actual outcome.
In summary, the rules for selecting test data for black box testing
using equivalence partitioning are:
1. partition the input data values
2. select representative data from each partition (equivalent data)
3. select data at the boundaries of partitions.
SELF-TEST QUESTION
Scenario testing is an approach to release testing where you devise typical scenarios of
use and use these to develop test cases for the system.
A scenario is a story that describes one way in which the system might be used.
Scenarios should be realistic and real system users should be able to relate to them.
In a short paper on scenario testing, Kaner (2003) suggests that a scenario test should
be a narrative story that is credible and fairly complex.
It should motivate stakeholders; that is, they should relate to the scenario and believe
that it is important that the system passes the test. He also suggests that it should be
easy to evaluate.
If there are problems with the system, then the release testing team should recognize
them.
C) PERFORMANCE TESTING
Once a system has been completely integrated, it is possible to test for evolving properties,
such as performance and reliability.
Performance tests have to be designed to ensure that the system can process its intended
load.
This usually involves running a series of tests where you increase the load until the system
performance becomes unacceptable.
Performance testing is concerned both with demonstrating that the system meets its
requirements and discovering problems and defects in the system.
To test whether performance requirements are being achieved, you may have to construct
an operational profile.
An operational profile is a set of tests that reflect the actual mix of work that will be
handled by the system.
Therefore, if 90% of the transactions in a system are of type A; 5% of type B; and the
remainder of types C, D, and E, then you have to design the operational profile so that the
vast majority of tests are of type A. Otherwise, you will not get an accurate test of the
operational performance of the system.
D) STRESS TESTING
An effective way to discover defects is to design tests around the limits of the
system.
In performance testing, this means stressing the system by making demands
that are outside the design limits of the software.
This is known as ‘stress testing’.
For example, say you are testing a transaction processing system that is
designed to process up to 300 transactions per second. You start by testing
this system with fewer than 300 transactions per second. You then gradually
increase the load on the system beyond 300 transactions per second until it
is well beyond the maximum design load of the system and the system fails.
STRESS TESTING
This type of testing has two functions:
1. It tests the failure behavior of the system. Circumstances may arise
through an unexpected combination of events where the load
placed on the system exceeds the maximum anticipated load. In
these circumstances, it is important that system failure should not
cause data corruption or unexpected loss of user services. Stress
testing checks that overloading the system causes it to ‘fail-soft’
rather than collapse under its load.
2. It stresses the system and may cause defects to come to light that
would not normally be discovered. Although it can be argued that
these defects are unlikely to cause system failures in normal
usage, there may be unusual combinations of normal
circumstances that the stress testing replicates.
3. USER TESTING
Beta testing is mostly used for software products that are used in many
different environments (as opposed to custom systems which are
generally used in a defined environment).
It is impossible for product developers to know and replicate all the
environments in which the software will be used.
Beta testing is therefore essential to discover interaction problems
between the software and features of the environment where it is used.
Beta testing is also a form of marketing— customers learn about their
system and what it can do for them.
C) ACCEPTANCE TESTING
3. Derive acceptance tests Once acceptance criteria have been established, tests
have to be designed to check whether or not a system is acceptable. Acceptance
tests should aim to test both the functional and non-functional characteristics
(e.g., performance) of the system. They should, ideally, provide complete
coverage of the system requirements. In practice, it is difficult to establish
completely objective acceptance criteria. There is often scope for argument about
whether or not a test shows that a criterion has definitely been met.
4. Run acceptance tests The agreed acceptance tests are executed on the
system. Ideally, this should take place in the actual environment where the
system will be used, but this may be disruptive and impractical. Therefore, a user
testing environment may have to be set up to run these tests. It is difficult to
automate this process as part of the acceptance tests may involve testing the
interactions between end-users and the system. Some training of end-users may
be required.
STAGES IN THE ACCEPTANCE TESTING PROCESS
5. Negotiate test results It is very unlikely that all of the defined
acceptance tests will pass and that there will be no problems with
the system. If this is the case, then acceptance testing is complete
and the system can be handed over. More commonly, some
problems will be discovered. In such cases, the developer and the
customer have to negotiate to decide if the system is good enough
to be put into use. They must also agree on the developer’s
response to identified problems.
6. Reject/accept system This stage involves a meeting between the
developers and the customer to decide on whether or not the
system should be accepted. If the system is not good enough for
use, then further development is required to fix the identified
problems. Once complete, the acceptance testing phase is
repeated.
OTHER TESTING METHODS