Chapter 8 Revision
Chapter 8 Revision
Chapter 8
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.
• Can reveal the presence of errors NOT their absence.
Testing is part of a more general verification and validation process, which also
includes static validation techniques.
2. 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.
Verification vs validation
Verification Validation
"Are we building the product right”. "Are we building the right product”.
The software should conform to its The software should do what the user
specification. really requires.
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.
1. Software purpose:
✓ The level of confidence depends on how critical the software is to an
organization.
2. User expectations:
✓ Users may have low expectations of certain kinds of software.
3. Marketing environment:
✓ Getting a product to market early may be more important than finding
defects in the program.
Software inspections
• These involve people examining the source representation with the aim of
discovering anomalies and defects.
Advantages of inspections
1. During testing, errors can mask (hide) other errors. Because inspection is a
static process, you don’t have to be concerned with interactions between errors.
Stages of testing
1. Development testing, where the system is tested during development
to discover bugs and defects.
Development testing
1. Development testing includes all testing activities that are carried out by the
team developing the system.
2. Unit testing, where individual program units or object classes are tested. Unit
testing should focus on testing the functionality of objects or methods.
5. System testing, where some or all the components in a system are integrated
and the system is tested. System testing should focus on testing component
interactions.
Unit testing
• Unit testing is the process of testing individual components in isolation.
• It is a defect testing process.
• Units may be:
1. Individual functions or methods within an object
2. Object classes with several attributes and methods
3. Composite components with defined interfaces used to access their
functionality.
Automated testing
• Whenever possible, unit testing should be automated so that tests are run
and checked without manual intervention.
3. An assertion part where you compare the result of the call with the
expected result. If the assertion evaluates to true, the test has been
successful. If false, then it has failed.
• If there are defects in the component, these should be revealed by test cases.
Testing strategies
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
• Input data and output results often fall into different classes where all
members of a class are related.
• Each of these classes is an equivalence partition or domain where the
program behaves in an equivalent way for each class member.
• Test cases should be chosen from each partition.
Equivalence partitioning
Equivalence partitions
Testing guidelines (sequences)
• Test software with sequences which have only a single value.
• Use sequences of different sizes in different tests.
• Derive tests so that the first, middle and last elements of the sequence are
accessed.
• Test with sequences of zero length.
Component testing
• Software components are often composite components that are made up of
several interacting objects.
• 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.
Interface testing
Interface testing
• Objectives are to detect faults due to interface errors or invalid assumptions
about interfaces.
• Interface types
1. Parameter interfaces Data passed from one method or procedure to
another.
2. Shared memory interfaces Block of memory is shared between
procedures or functions.
3. Procedural interfaces Sub-system encapsulates a set of procedures to be
called by other sub-systems.
4. Message passing interfaces Sub-systems request services from other
sub-systems.
Interface errors
1. Interface misuse
✓ A calling component calls another component and makes an error in its
use of its interface e.g. parameters in the wrong order.
2. Interface misunderstanding
✓ A calling component embeds assumptions about the behavior of the
called component which are incorrect.
3. Timing errors
✓ The called and the calling component operate at different speeds and
out-of-date information is accessed.
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 behavior of a system.
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.
In some companies, system testing may involve separate testing teams with no
involvement from designers and programmers.
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 document the
components and interactions that are being tested.
Test-driven development
• Test-driven development (TDD) is an approach to program development in
which your 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.
Test-driven development
2. Regression testing
✓ A regression test suite is developed incrementally as a program is
developed.
3. Simplified debugging
✓ When a test fails, it should be obvious where the problem lies. The
newly written code needs to be checked and modified.
4. System documentation
✓ The tests themselves are a form of documentation that describe what
the code should be doing.
Regression testing
• Regression testing is testing the system to check that changes have not
‘broken’ previously working code.
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.
Requirements tests
• Set up a patient record with no known allergies. Prescribe medication for
allergies that are known to exist. Check that a warning message is not issued
by the system.
• Set up a patient record with a known allergy. Prescribe the medication to that
the patient is allergic to, and check that the warning is issued by the system.
• Set up a patient record in which allergies to two or more drugs are recorded.
Prescribe both of these drugs separately and check that the correct warning
for each drug is issued.
• Prescribe two drugs that the patient is allergic to. Check that two warnings are
correctly issued.
• Prescribe a drug that issues a warning and overrule that warning. Check that
the system requires the user to provide information explaining why the
warning was overruled.
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.
User testing
1. User or customer testing is a stage in the testing process in which users or
customers provide input and advice on system testing.
2. User testing is essential, even when comprehensive system and release
testing have been carried out.
3. 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.
• Tests are defined by the user/customer and are integrated with other tests in
that they are run automatically when changes are
made.
• Main problem here is whether or not the embedded user is ‘typical’ and can
represent the interests of all system stakeholders.
Questions
1. https://quizlet.com/445098903/chapter-8-software-engineering-global-
edition-2019-10th-sommerville-flash-cards/
2. https://quizlet.com/253573948/software-engineering-ch8-flash-cards/