2. Program Testing
Testing is intended to show that a program does
what it is intended to do and to discover program
defects before it is put into use. When you test
software, you execute a program using artificial
data.
You check the results of the test run for errors,
anomalies or information about the program’s non-
functional attributes.
Testing is part of a more general verification and
validation process, which also includes static
validation techniques. It can reveal the presence of
errors NOT their absence.
Lecture 11 Software Testing 2
3. Program Testing Goals
To demonstrate to the developer and the customer that
the software meets its requirements.
For custom software, this means that there should be at least
one test for every requirement in the requirements document.
For generic software products, it means that there should be
tests for all of the system features, plus combinations of these
features, that will be incorporated in the product release.
To discover situations in which the behavior of the
software is incorrect, undesirable or does not conform to
its specification.
Defect testing is concerned with rooting out undesirable system
behavior such as system crashes, unwanted interactions with
other systems, incorrect computations and data corruption.
3
Lecture 11 Software Testing
4. Validation and Defect Testing
The first goal leads to validation testing
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
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.
4
Lecture 11 Software Testing
5. Testing Process Goals
Validation Testing
To demonstrate to the developer and the system
customer that the software meets its requirements
A successful test shows that the system operates as
intended.
Defect Testing
To discover faults or defects in the software where its
behavior is incorrect or not in conformance with its
specification
A successful test is a test that makes the system
perform incorrectly and so exposes a defect in the
system.
5
Lecture 11 Software Testing
7. Verification:
"Are we building the product right”.
The software should conform to its specification.
Validation:
"Are we building the right product”.
The software should do what the user really requires.
Verification vs Validation
7
Lecture 11 Software Testing
8. V & V Confidence
Aim of V & V is to establish confidence that the system
is ‘fit for purpose’.
Depends on system’s purpose, user expectations and
marketing environment
Software purpose
• The level of confidence depends on how critical the software
is to an organisation.
User expectations
• Users may have low expectations of certain kinds of
software.
Marketing environment
• Getting a product to market early may be more important
than finding defects in the program.
8
Lecture 11 Software Testing
9. Software Inspections: concerned with analysis of
the static system representation to discover
problems (static verification)
May be supplement by tool-based document and
code analysis.
Software Testing: concerned with exercising and
observing product behaviour (dynamic verification)
The system is executed with test data and its
operational behaviour is observed.
Inspections and Testing
9
Lecture 11 Software Testing
11. Software Inspections
These involve people examining the source
representation with the aim of discovering anomalies
and defects.
Inspections not require execution of a system so may
be used before implementation.
They may be applied to any representation of the
system (requirements, design, configuration data, test
data, etc.).
They have been shown to be an effective technique
for discovering program errors.
11
Lecture 11 Software Testing
12. A model of the software testing process
12
Lecture 11 Software Testing
13. Stages of Testing
Development Testing
Where the system is tested during development to
discover bugs and defects.
Release Testing
Where a separate testing team test a complete
version of the system before it is released to users.
User Testing
Where users or potential users of a system test the
system in their own environment.
Lecture 11 Software Testing 13
14. Development Testing
Development testing includes all testing activities that
are carried out by the team developing the system.
Unit Testing: where individual program units or object
classes are tested. Unit testing should focus on testing
the functionality of objects or methods.
Component Testing: where several individual units are
integrated to create composite components. Component
testing should focus on testing component interfaces.
System Testing: where some or all of the components
in a system are integrated and the system is tested as a
whole. System testing should focus on testing
component interactions.
Lecture 11 Software Testing 14
15. Unit Testing
Unit testing is the process of testing individual
components in isolation.
It is a defect testing process.
Units may be:
Individual functions or methods within an object
Object classes with several attributes and methods
Composite components with defined interfaces used
to access their functionality.
15
Lecture 11 Software Testing
16. Component Testing
Software components are often composite components
that are made up of several interacting objects.
For example, in the weather station system, the reconfiguration
component includes objects that deal with each aspect of the
reconfiguration.
You access the functionality of these objects through the
defined component interface.
Testing composite components should therefore focus
on showing that the component interface behaves
according to its specification.
You can assume that unit tests on the individual objects within
the component have been completed.
Lecture 11 Software Testing 16
17. System Testing
System testing during development involves
integrating components to create a version of the
system and then testing the integrated system.
The focus in system testing is testing the
interactions between components.
System testing checks that components are
compatible, interact correctly and transfer the right
data at the right time across their interfaces.
System testing tests the emergent behaviour of a
system.
17
Lecture 11 Software Testing
18. System and Component Testing
During system testing, reusable components that
have been separately developed and off-the-shelf
systems may be integrated with newly developed
components. The complete system is then tested.
Components developed by different team members
or sub-teams may be integrated at this stage.
System testing is a collective rather than an
individual process.
In some companies, system testing may involve a
separate testing team with no involvement from
designers and programmers.
Lecture 11 Software Testing 18
19. Use-case Testing
The use-cases developed to identify system
interactions can be used as a basis for system
testing.
Each use case usually involves several system
components so testing the use case forces these
interactions to occur.
The sequence diagrams associated with the use
case documents the components and interactions
that are being tested.
Lecture 11 Software Testing 19
20. Test-Driven Development (TDD)
Test-driven development (TDD) is an approach to
program development in which you inter-leave testing
and code development. Tests are written before code
and ‘passing’ the tests is the critical driver of
development.
You develop code incrementally, along with a test for
that increment. You don’t move on to the next
increment until the code that you have developed
passes its test.
TDD was introduced as part of agile methods such as
Extreme Programming. However, it can also be used
in plan-driven development processes.
20
Lecture 11 Software Testing
22. Benefits of Test-driven Development
Code coverage
Every code segment that you write has at least one associated
test so all code written has at least one test.
Regression testing
A regression test suite is developed incrementally as a
program is developed.
Simplified debugging
When a test fails, it should be obvious where the problem lies.
The newly written code needs to be checked and modified.
System documentation
The tests themselves are a form of documentation that
describe what the code should be doing.
22
Lecture 11 Software Testing
23. Regression Testing
Regression testing is testing the system to check
that changes have not ‘broken’ previously
working code.
In a manual testing process, regression testing
is expensive but, with automated testing, it is
simple and straightforward.
All tests are rerun every time a change is made
to the program.
Tests must run ‘successfully’ before the change
is committed.
23
Lecture 11 Software Testing
24. Release Testing
Release testing is the process of testing a particular
release of a system that is intended for use outside of
the development team.
The primary goal of the release testing process is to
convince the supplier of the system that it is good
enough for use.
Release testing, therefore, has to show that the system
delivers its specified functionality, performance and
dependability, and that it does not fail during normal use.
Release testing is usually a black-box testing process
where tests are only derived from the system
specification.
24
Lecture 11 Software Testing
25. Performance Testing
Part of release testing may involve testing the
emergent properties of a system, such as
performance and reliability.
Tests should reflect the profile of use of the system.
Performance tests usually involve planning a series
of tests where the load is steadily increased until the
system performance becomes unacceptable.
Stress testing is a form of performance testing
where the system is deliberately overloaded to test
its failure behavior.
25
Lecture 11 Software Testing
26. User Testing
User or customer testing is a stage in the testing
process in which users or customers provide input
and advice on system testing.
User testing is essential, even when comprehensive
system and release testing have been carried out.
The reason for this is that influences from the user’s
working environment have a major effect on the
reliability, performance, usability and robustness of a
system.
These cannot be replicated in a testing environment.
26
Lecture 11 Software Testing
27. Types of User Testing
Alpha Testing
Users of the software work with the development
team to test the software at the developer’s site.
Beta Testing
A release of the software is made available to users
to allow them to experiment and to raise problems
that they discover with the system developers.
Acceptance Testing
Customers test a system to decide whether or not it is
ready to be accepted from the system developers and
deployed in the customer environment. Primarily for
custom systems.
27
Lecture 11 Software Testing
28. Agile Methods and Acceptance Testing
In agile methods, the user/customer is part of the
development team and is responsible for making
decisions on the acceptability of the system.
Tests are defined by the user/customer and are
integrated with other tests in that they are run
automatically when changes are made.
There is no separate acceptance testing process.
Main problem here is whether or not the embedded
user is ‘typical’ and can represent the interests of all
system stakeholders.
28
Lecture 11 Software Testing