Ch8 Handouts
Ch8 Handouts
² Test-driven development
Software Testing ² Release testing
² User testing
Chapter 8
Dr. Mahmood Qureshi Hashmi
Assistant Professor
Department of Electrical & Computer Engineering Chapter 8 So;ware tes=ng 2
² Testing is intended to show that a program does what it is ² To demonstrate that the software meets its requirements.
intended to do and to discover program defects before it is put § For custom soft`ware, this means that there should be at least
into use. one test for every requirement in the requirements document.
² When you test software, you execute a program using For generic software products, it means that there should be
artificial data. tests for all of the system features, plus combinations of these
features, that will be incorporated in the product release.
² You check the results of the test run for errors, anomalies or
² To discover situations in which the behavior of the
information about the program’s non-functional attributes.
software is incorrect, undesirable or does not conform to
² Can reveal the presence of errors NOT their absence. its specification.
² Testing is part of a more general verification and validation § Defect testing is concerned with rooting out undesirable system
process, which also includes static validation techniques. behavior such as system crashes, unwanted interactions with
other systems, incorrect computations and data corruption.
Chapter 8 So;ware tes=ng 3 Chapter 8 So;ware tes=ng 4
² 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.
§ To discover faults or deffects in the software
The differences between validation testing and defect testing
Chapter 8 So;ware tes=ng 5 Chapter 8 So;ware tes=ng 6
• Verification: • Aim of V & V is to establish confidence that the system is
"Are we building the product right”. ‘fit for purpose’.
• The software should conform to its specification. • Depends on system’s purpose, user expectations and
marketing environment
• Validation: • Software purpose
"Are we building the right product”. • The level of confidence depends on how critical the software
is to an organisation.
• The software should do what the user really • User expectations
requires. • 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.
Chapter 8 So;ware tes=ng 7 Chapter 8 So;ware tes=ng 8
² Software inspections: Carefully checking the
software's design or code without running it. (static
verification).
●
The goal is to find problems or errors by reviewing the software
itself. Sometimes, special tools are also used to help check
documents and code for mistakes.
² Software testing Concerned with exercising and
observing product behaviour (dynamic verification)
§ The system is executed with test data and its operational
behaviour is observed.
Software inspections and testing support V & V at different stages in the software process. The
arrows indicate the stages in the process where the techniques may be used.
Chapter 8 So;ware tes=ng 9 Chapter 8 So;ware tes=ng 10
• Examining the source representation with the aim of ² During testing, errors can mask (hide) other errors. But
discovering anomalies and defects. with inspections (since nothing runs), you don't have to
• Inspections not require execution of a system so may be worry about that.
used before implementation.
² Incomplete versions of a system can be inspected
• They may be applied to any representation of the system without additional costs. If a program is incomplete, then
(requirements, design,configuration data, test data, etc.). You need to create extra tools to test the available parts
• Proven and effective technique for discovering program
² Inspections don't just find bugs—they also check if the
errors.
program follows rules, and if it's easy to move and
maintain.
Chapter 8 So;ware tes=ng 11 Chapter 8 So;ware tes=ng 12
² 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.
An abstract model of the ‘traditional’ testing process, as used in plan driven development.
Chapter 8 So;ware tes=ng 13 Chapter 8 So;ware tes=ng 14
² 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.
Chapter 8 So;ware tes=ng 15 Chapter 8 So;ware tes=ng 16
• Unit testing is the process of testing individual • Complete test coverage of a class involves
components in isolation. • Testing all operations associated with an object
• It is a defect testing process. • Put the objects into all possible states. (Should simulate
all events that cause a state change)
• Units may be:
• Individual functions or methods within an object
• Object classes with several attributes and methods The object has one important piece of information: its
• Composite components with defined interfaces used identifier, which stays the same once the weather station is
set up. You need to create test cases for each method it
to access their functionality. uses, like checking weather reports, status updates, and
more.
Chapter 8 Software testing 17 Chapter 8 Software testing 18
• Need to define test cases for reportWeather, calibrate, ² Partition Testing, where you identify groups of inputs that
test, startup and shutdown. have common characteristics and should be processed
• Using a state model, identify sequences of state in the same way.
transitions to be tested and the event sequences to cause § You should choose tests from within each of these groups.
these transitions (should try every possible state transistion sequence) ² Guideline-Based Testing, where you use testing
• For example: (state sequences) guidelines to choose test cases.
• Shutdown -> Running-> Shutdown § These guidelines reflect previous experience of the kinds of
• Configuring-> Running-> Testing -> Transmitting -> Running errors that programmers often make when developing
components.
• Running-> Collecting-> Running-> Summarizing -> Transmitting -
> Running
Chapter 8 Software testing 19 Chapter 8 So;ware tes=ng 20
• Input data and output results often fall into different
classes where all members of a class are related.
●
If you’re testing a login form, input like valid usernames and passwords
would belong to one group, and invalid usernames or passwords to another
group.
• Each of these classes is an equivalence partition or
domain where the program behaves in an equivalent way
for each class member.
●
If you're testing numbers in a range (like ages), all inputs between 18-60
might behave the same way. So, instead of testing every number, you can
test one and assume the others will work the same.
• Test cases should be chosen from each partition.
The large shaded ellipse on the left represents the set of all possible inputs to the
●
When creating test cases, pick one or more examples from each group program that is being tested. The smaller unshaded ellipses represent equivalence
partitions.
Chapter 8 Software testing 21 Chapter 8 So;ware tes=ng 22
• Based on Experience: Testing guidelines are built from past ² Software components are often composite components
experiences and common mistakes programmers make, helping to catch
errors more effectively. that are made up of several interacting objects.
§ For example, in the weather station system, the reconfiguration
• Common Error Patterns: Target the known error patterns, such as component includes objects that deal with each aspect of the
boundary issues, incorrect calculations, or missing edge cases.
reconfiguration.
• Error-prone Areas: Guidelines often focus on specific areas like input ² You access the functionality of these objects through the
validation, data handling, and system boundaries where issues frequently
arise. defined component interface.
• Covers Critical Scenarios: Ensures important scenarios, such as ² Testing composite components should therefore focus
invalid inputs, edge conditions, or extreme cases, are tested thoroughly. 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.
Chapter 8 Software testing 23 Chapter 8 So;ware tes=ng 24
² Objectives are to detect faults due to interface errors or
invalid assumptions about interfaces.
² Interface types
§ Parameter interfaces Data passed from one method or
procedure to another.
§ Shared memory interfaces Block of memory is shared between
procedures or functions.
§ Procedural interfaces Sub-system encapsulates a set of
procedures to be called by other sub-systems.
§ Message passing interfaces Sub-systems request services from
other sub-systems
Illustrates the idea of component interface testing. Assume that components A, B, and C
have been integrated to create a larger component or subsystem.
Chapter 8 So;ware tes=ng 25 Chapter 8 So;ware tes=ng 26
² Interface misuse ² Create tests where the inputs to a function are at the
§ A calling component calls another component and makes an highest and lowest possible values.
error in its use of its interface e.g. parameters in the wrong
² Always test pointer parameters with null pointers.
order.
² Interface misunderstanding ² Design tests which cause the component to fail.
§ A calling component embeds assumptions about the behaviour ² Use stress testing in message passing systems.
of the called component which are incorrect.
² In shared memory systems, vary the order in which
² Timing errors components are activated.
§ The called and the calling component operate at different
speeds and out-of-date information is accessed.
Chapter 8 So;ware tes=ng 27 Chapter 8 So;ware tes=ng 28
² System testing during development involves integrating ² In system testing, ready-made parts and separately
components to create a version of the system and then developed components are combined with new ones,
testing the integrated system. and the whole system is tested together.
² The focus in system testing is testing the interactions ² Components developed by different team members or
between components. sub-teams may be integrated at this stage.
² System testing checks that components are compatible, ² System testing is a collective rather than an individual
interact correctly and transfer the right data at the right process.
time across their interfaces. § In some companies, system testing may involve a separate
testing team with no involvement from designers and
² System testing tests the emergent behaviour of a
programmers.
system.
Chapter 8 So;ware tes=ng 29 Chapter 8 So;ware tes=ng 30
² The use cases created to show how the system works
can be used to help test the system.
² 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.
Chapter 8 So;ware tes=ng 31 32
² Exhaustive system testing is impossible so testing ² Test-driven development (TDD) is an approach to
policies which define the required system test coverage program development in which you inter-leave testing
may be developed. and code development.
² Examples of testing policies: ² Tests are written before code and ‘passing’ the tests is
§ All system functions that are accessed through menus should be the critical driver of development.
tested.
² You develop code incrementally, along with a test for that
§ Combinations of functions (e.g. text formatting) that are
increment. You don’t move on to the next increment until
accessed through the same menu must be tested.
the code that you have developed passes its test.
§ Where user input is provided, all functions must be tested with
both correct and incorrect input. ² TDD was introduced as part of agile methods such as
Extreme Programming. However, it can also be used in
plan-driven development processes.
Chapter 8 So;ware tes=ng 33 Chapter 8 So;ware tes=ng 34
² Start by identifying the increment of functionality that is
required. This should normally be small and
implementable in a few lines of code.
² Write a test for this functionality and implement this as an
automated test.
² Run the test, along with all other tests that have been
implemented. Initially, you have not implemented the
functionality so the new test will fail.
² Implement the functionality and re-run the test.
² Once all tests run successfully, you move on to
implementing the next chunk of functionality.
Chapter 8 So;ware tes=ng 35 Chapter 8 So;ware tes=ng 36
² Code coverage
² Regression testing is testing the system to check that
§ Every code segment that you write has at least one associated
changes have not ‘broken’ previously working code.
test so all code written has at least one test.
² Regression testing ² In a manual testing process, regression testing is
expensive but, with automated testing, it is simple and
§ A regression test suite is developed incrementally as a program
is developed. Changes to the programs have not introduced new
straightforward. All tests are re-run every time a change
bugs. is made to the program.
² Simplified debugging ² Tests must run ‘successfully’ before the change is
§ When a test fails, it should be obvious where the problem lies. committed.
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.
Chapter 8 So;ware tes=ng 37 Chapter 8 So;ware tes=ng 38
² Release testing is the process of testing a particular release ² Release testing is a form of system testing.
of a system that is intended for use outside of the ² Important differences:
development team.
§ A separate team that has not been involved in the system
² The primary goal of the release testing process is to development, should be responsible for release testing.
convince the supplier of the system that it is good enough § System testing by the development team should focus on
for use. discovering bugs in the system (defect testing). The objective of
release testing is to check that the system meets its
§ Release testing, therefore, has to show that the system delivers its
requirements and is good enough for external use (validation
specified functionality, performance and dependability, and that it
testing).
does not fail during normal use.
² Release testing is usually a black-box testing process
where tests are only derived from the system specification.
Chapter 8 So;ware tes=ng 39 Chapter 8 So;ware tes=ng 40
² Requirements-based testing involves examining each ² 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
requirement and developing a test or tests for it. issued by the system.
² MHC-PMS requirements: ² 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
§ If a patient is known to be allergic to any particular medication,
system.
then prescription of that medication shall result in a warning
message being issued to the system user. ² 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
§ If a prescriber chooses to ignore an allergy warning, they shall
for each drug is issued.
provide a reason why this has been ignored.
² 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.
Chapter 8 So;ware tes=ng 41 Chapter 8 So;ware tes=ng 42
Kate is a nurse who specializes in mental health care. One of her responsibilities
² Authentication by logging on to the system. is to visit patients at home to check that their treatment is effective and that they
are not suffering from medication side -effects.
² Downloading and uploading of specified patient records On a day for home visits, Kate logs into the MHC-PMS and uses it to print her
schedule of home visits for that day, along with summary information about the
to a laptop. patients to be visited. She requests that the records for these patients be
downloaded to her laptop. She is prompted for her key phrase to encrypt the
² Home visit scheduling. records on the laptop.
One of the patients that she visits is Jim, who is being treated with medication for
² Encryption and decryption of patient records on a mobile depression. Jim feels that the medication is helping him but believes that it has the
device. side -effect of keeping him awake at night. Kate looks up Jim’s record and is
prompted for her key phrase to decrypt the record. She checks the drug
² Record retrieval and modification. prescribed and queries its side effects. Sleeplessness is a known side effect so
she notes the problem in Jim’s record and suggests that he visits the clinic to have
² Links with the drugs database that maintains side-effect his medication changed. He agrees so Kate enters a prompt to call him when she
gets back to the clinic to make an appointment with a physician. She ends the
information. consultation and the system re-encrypts Jim’s record.
After, finishing her consultations, Kate returns to the clinic and uploads the records
² The system for call prompting. of patients visited to the database. The system generates a call list for Kate of
those patients who she has to contact for follow-up information and make clinic
Chapter 8 So;ware tes=ng 43 Chapter 8 So;ware tes=ng 44
appointments.
• Part of release testing may involve testing the emergent ² User or customer testing is a stage in the testing process
properties of a system, such as performance and in which users or customers provide input and advice on
reliability. system testing.
• Tests should reflect the profile of use of the system. ² User testing is essential, even when comprehensive
• Performance tests usually involve planning a series of system and release testing have been carried out.
tests where the load is steadily increased until the system § The reason for this is that influences from the user’s working
performance becomes unacceptable. environment have a major effect on the reliability, performance,
usability and robustness of a system. These cannot be
• Stress testing is a form of performance testing where the replicated in a testing environment.
system is deliberately overloaded to test its failure
behaviour.
Chapter 8 Software testing 45 Chapter 8 So;ware tes=ng 46
² 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. There are six stages in the acceptance testing process
Chapter 8 So;ware tes=ng 47 Chapter 8 So;ware tes=ng 48
² Define acceptance criteria ² In agile methods, the user/customer is part of the
² Plan acceptance testing development team and is responsible for making
decisions on the acceptability of the system.
² Derive acceptance tests
² Tests are defined by the user/customer and are
² Run acceptance tests integrated with other tests in that they are run
² Negotiate test results automatically when changes are made.
² Reject/accept system ² There is no separate acceptance testing process.
² See page 230 for further reading
Chapter 8 So;ware tes=ng 49 Chapter 8 So;ware tes=ng 50
² When testing software, you should try to ‘break’ the software by
using experience and guidelines to choose types of test case that
have been effective in discovering defects in other systems.
² Wherever possible, you should write automated tests. The tests are
embedded in a program that can be run every time a change is
made to a system.
² Test-first development is an approach to development where tests
are written before the code to be tested.
² Scenario testing involves inventing a typical usage scenario and
using this to derive test cases.
² Acceptance testing is a user testing process where the aim is to
decide if the software is good enough to be deployed and used in its
operational environment.
Chapter 8 So;ware tes=ng 51