Module 1 Final
Module 1 Final
Testing
Module 1
Introduction
Module - 1 (Introduction to Software Testing)
Some Popular Errors – Ariane 5, Therac 25, Intel Pentium Bug. What is
Software testing? Why should it be tested? Software Quality, Role of
Testing. Testing Process - Level 0 thinking, Level 1 thinking, Level 2
thinking, Level 3 thinking, Level 4 thinking. Software Testing
Terminologies - Verification, Validation and Testing, Faults, Error and
Bug, Test cases, Coverage Criteria. Types of Testing- Unit testing,
integration testing, System testing, Acceptance testing, Beta testing,
Functional testing, Stress testing, Performance testing, Usability
testing, and Regression testing. Testing Methods - Black Box testing,
WhiteBox testing, Grey Box testing.
2
Testing in the 21st Century
• Software defines behavior
• network routers, finance, switching networks, other infrastructure
• Today’s software market :
• is much bigger Industry is going through
• is more competitive a revolution in what
• has more users testing means to the
• Embedded Control Applications success of software
• airplanes, air traffic control – PDAs products
• spaceships – memory seats
• watches – DVD players
• ovens – garage door openers
• remote controllers – cell phones
• Defect • Failure
• Fault • Inconsistency
• Problem • Product
• Error Anomaly
• Incident • Product
• Anomaly Incidence
• Variance • Feature :-)
Costly Software Failures
NIST report, “The Economic Impacts of Inadequate Infrastructure for
Software Testing” (2002)
– Inadequate software testing costs the US alone between $22 and $59 billion
annually
– Better approaches could cut this amount in half
Huge losses due to web application failures
– Financial services : $6.5 million per hour (just in USA!)
– Credit card sales applications : $2.4 million per hour (in USA)
In Dec 2006, [Link]’s BOGO offer turned into a double discount
2007 : Symantec says that most security vulnerabilities are due to
faulty software
7
NASA’s Mars lander: September 1999, crashed
due to a units integration fault
Spectacular Software Failures Ariane 5:
Mars Polar exception-handling
Lander crash bug : forced self
site? destruct on maiden
flight (64-bit to 16-bit
Toyota brakes : Dozens dead, thousands of conversion: about
crashes 370 million $ lost)
Major failures: Ariane 5 explosion, Mars Polar
Lander, Intel’s Pentium FDIV bug
Poor testing of safety-critical software can cost
lives :
THERAC-25 radiation machine: 3 dead THERAC-25 design
10
Pentium Fails Long Division (1993)
• Cost: $475 million, corporate credibility
• Disaster: Intel’s highly-promoted Pentium chip occasionally made
mistakes when dividing floating-point numbers within a specific
range. For example, dividing 4195835.0/3145727.0 yielded 1.33374
instead of 1.33382, an error of 0.006%. Although the bug affected
few users, it become a public relations nightmare. With an estimated
5 million defective chips in circulation, Intel offered to replace
Pentium chips only for consumers who could prove they needed high
accuracy. Eventually Intel replaced the chips for anyone who
complained.
• Cause: The divider in the Pentium floating point unit had a flawed
division table, missing about five of a thousand entries and resulting
in these rounding errors.
Airbus 319 Safety Critical
Software Control
Loss of autopilot
Affected 10 million
people in Ontario,
Canada
Affected 40 million
people in 8 US
states
Financial losses of
$6 Billion USD
14
Testing in the 21st Century
• More safety critical, real-time software
• Embedded software is ubiquitous … check your pockets
• Enterprise applications means bigger programs, more users
• Paradoxically, free software increases our expectations !
• Security is now all about software faults
• Secure software is reliable software
• The web offers a new deployment platform
• Very competitive and very available to more users
• Web apps are distributed
• Web apps must be highly reliable
16
What is..........
Software Testing Definition
• Software testing is a process,
• to evaluate the functionality of a software application
with an intent
• to find whether the developed software met the specified
requirements or not and
• to identify the defects
• to ensure that the product is defect-free in order to
produce the quality product.
Test Design in Context
• Test Design is the process of designing input values
that will effectively test software
19
Types of Test Activities
• Testing can be broken up into four general types of activities
1. Test Design 1.a) Criteria-based
2. Test Automation 1.b) Human-based
3. Test Execution
4. Test Evaluation
• Each type of activity requires different skills, background knowledge,
education and training
• No reasonable software development organization uses the same
people for requirements, design, implementation, integration and
configuration control
20
1. Test Design – (a) Criteria-Based
• This is the most technical job in software testing
• Requires knowledge of :
• Discrete math
• Programming
• Testing
• Requires much of a traditional CS degree
• This is intellectually stimulating, rewarding, and challenging
• Test design is analogous to software architecture on the development
side
• Using people who are not qualified to design tests is a sure way to get
ineffective tests
21
1. Test Design – (b) Human-Based
• This is much harder than it may seem to developers
• Criteria-based approaches can be blind to special situations
• Requires knowledge of :
• Domain, testing, and user interfaces
• Requires almost no traditional CS
• A background in the domain of the software is essential
• An empirical background is very helpful (biology, psychology, …)
• A logic background is very helpful (law, philosophy, math, …)
• This is intellectually stimulating, rewarding, and challenging
• But not to typical CS majors – they want to solve problems and
build things
22
2. Test Automation
• This is slightly less technical
• Requires knowledge of programming
• Fairly straightforward programming – small pieces and simple
algorithms
• Requires very little theory
• Very boring for test designers
• Programming is out of reach for many domain experts
• Who is responsible for determining and embedding the expected
outputs ?
• Test designers may not always know the expected outputs
• Test evaluators need to get involved early to help with this
23
3. Test Execution
• This is easy – and trivial if the tests are well automated
• Requires basic computer skills
• Interns
• Employees with no technical background
• Asking qualified test designers to execute tests is a sure
way to convince them to look for a development job
• If, for example, GUI tests are not well automated, this
requires a lot of manual labor
• Test executors have to be very careful and meticulous with
bookkeeping
24
4. Test Evaluation
• This is much harder than it may seem
• Requires knowledge of :
• Domain
• Testing
• User interfaces and psychology
• Usually requires almost no traditional CS
• A background in the domain of the software is essential
• An empirical background is very helpful (biology, psychology, …)
• A logic background is very helpful (law, philosophy, math, …)
• This is intellectually stimulating, rewarding, and challenging
• But not to typical CS majors – they want to solve problems and
build things
25
Other Activities
• Test management: Sets policy, organizes team, interfaces with development,
chooses criteria, and decides how much automation is needed, …
• Test maintenance: Save tests for reuse as software evolves
• Requires cooperation of test designers and automators
• Deciding when to trim the test suite is partly policy and partly technical –
and in general, very hard !
• Tests should be put in configuration control
• Test documentation : All parties participate
• Each test must document “why” – criterion and test requirement satisfied
or a rationale for human-designed tests
• Ensure traceability throughout the process
• Keep documentation in the automated tests
26
Types of Test Activities – Summary
1a. Design Design test values to satisfy engineering goals
Criteria Requires knowledge of discrete math, programming and
testing
1b. Design Design test values from domain knowledge and intuition
Human Requires knowledge of domain, UI, testing
2. Automation Embed test values into executable scripts
Requires knowledge of scripting
3. Execution Run tests on the software and record the results
Requires very little knowledge
4. Evaluation Evaluate results of testing, report to developers
Requires domain knowledge
• These four general test activities are quite different
• It is a poor use of resources to use people inappropriately
27
Organizing the Team
• A mature test organization needs only one test designer to work with several
test automators, executors and evaluators
• Putting the wrong people on the wrong tasks leads to inefficiency, low job
satisfaction and low job performance
• A qualified test designer will be bored with other tasks and look for a job in
development
• A qualified test evaluator will not understand the benefits of test criteria
• Test evaluators have the domain knowledge, so they must be free to add tests
that “blind” engineering processes will not think of
28
Model-Driven Test Design
refined
model / test
requirements /
structure requirements
test specs
test
requirements DESIGN
ABSTRACTION
LEVEL
IMPLEMENTATION
software ABSTRACTION
artifact LEVEL input
values
29
Model-Driven Test Design – Steps
criterion refine refined
model / test
requirements /
structure requirements
test specs generate
analysis test
domain
requirements DESIGN
analysis ABSTRACTION
LEVEL
IMPLEMENTATION
software ABSTRACTION
artifact LEVEL input
values
execute prefix
evaluate automate
postfix
pass / test test test expected
fail results scripts cases
30
Model-Driven Test Design –
Activities refined
model / test
requirements /
structure requirements
test specs
Test Design DESIGN
ABSTRACTION
LEVEL
Raising our abstraction level makes
IMPLEMENTATION
ABSTRACTION
software
test design MUCH easier
LEVEL input
artifact values
32
Example (2)
Graph Edges 6 requirements for
Abstract version 12 Edge-Pair Coverage
1 23 1. [1, 2, 3]
32 2. [1, 2, 5]
34 3. [2, 3, 4]
2 25 4. [2, 3, 2]
Initial Node: 1 5. [3, 2, 3]
3 Final Nodes: 4, 5 6. [3, 2, 5]
Test Paths
5 4 [1, 2, 5]
[1, 2, 3, 2, 5] Find values …
[1, 2, 3, 2, 3, 4] 33
Goal of a software tester
• … to find bugs
• … as early in the software development processes as possible
• … and make sure they get fixed.
How to define Software Testing
Principles
• Testing
The execution of a program to find its faults
• Verification
The process of proving the programs correctness.
• Validation
The process of finding errors by executing the program in a real
environment
• Debugging
Diagnosing the error and correct it
Fundamentals of Software Testing
Verification ????? Validation ??????
Validation & Verification (IEEE)
• Validation: The process of evaluating software at the end
of software development to ensure compliance with
intended usage
37
Verification & Validation-Example
Lets say we are writing a program for addition.
a+b = c
42
Static and Dynamic Testing
• Static Testing: Testing without executing the program.
• This includes software inspections and some forms of analyses
• Very effective at finding certain kinds of problems – especially
“potential” faults, that is, problems that could lead to faults
when the program is modified
43
Software Faults, Errors & Failures
• Software Fault: A static defect in the software
44
Testing & Debugging
• Testing: Finding inputs that cause the software to
fail
45
Fault & Failure Model
Three conditions necessary for a failure to be observed
46
Test Case
• Test Case Values: The values that directly satisfy one test
requirement
47
Testing Goals Based on Test Process Maturity
▪ Level 0 : There’s no difference between testing and debugging
48
Level 0 Thinking
• Testing is the same as debugging
49
Level 1 Thinking
• Purpose is to show correctness
• Correctness is impossible to achieve
• What do we know if no failures?
• Good software or bad tests?
• Test engineers have no:
• Strict goal
• Real stopping rule
• Formal test technique
• Test managers are powerless
55
Software Testing Foundations
56
Testing & Debugging
• Testing : Evaluating software by observing its execution
58
RIPR Model
Test
Final Program State
Reaches Observed Final
• Reachability Observed
Program State
Final Program
• Infection Fault State
Incorrect
Final
Infects
• Propagation State
Propagates Reveals
• Revealability Incorrect
Program
State Test
Oracles
59
Traditional Testing Levels Acceptance testing : Is
main Class P the software acceptable
to the user?
Class A Class B
Intra-class testing : Test an
method mA1() method mB1() entire class as sequences
of calls
method mA2() method mB2()
Inter-method testing :
Test pairs of methods in
the same class
Intra-method testing :
Test each method
individually
61
New : Test Coverage Criteria
A tester’s job is simple : Define a model of the software, then find
ways to cover it
64
Test Requirements and Criteria
• Test Criterion : A collection of rules and a process that define test
requirements
̶ Cover every statement
̶ Cover every functional requirement
• Test Requirements : Specific things that must be satisfied or covered
during testing
• Each statement might be a test requirement
• Each functional requirement might be a test requirement
Testing researchers have defined dozens of criteria, but they are
all really just a few criteria on four types of structures …
66
Criteria Based on Structures
Structures : Four ways to model software
if (x > y)
4. Syntactic Structures else
z = x - y;
(grammars) z = 2 * x;
67
Example : Jelly Bean Coverage
Flavors : Colors :
1. Lemon 1. Yellow (Lemon, Apricot)
2. Pistachio 2. Green (Pistachio)
3. Cantaloupe 3. Orange (Cantaloupe,
4. Pear Tangerine)
5. Tangerine 4. White (Pear)
6. Apricot
68
Coverage
Given a set of test requirements TR for coverage
criterion C, a test set T satisfies C coverage if and only
if for every test requirement tr in TR, there is at least
one test t in T such that t satisfies tr
• Infeasible test requirements : test requirements that
cannot be satisfied
• No test case values exist that meet the test requirements
• Example: Dead code
• Detection of infeasible test requirements is formally undecidable for most
test criteria
• Thus, 100% coverage is impossible in practice
69
More Jelly Beans
T1 = { three Lemons, one Pistachio, two Cantaloupes,
one Pear, one Tangerine, four Apricots }
• Does test set T1 satisfy the flavor criterion ?
70
Types of Testing
• Levels of testing include different methodologies that can be
used while conducting software testing.
• The main levels of software testing are −
• Functional Testing
• Non-functional Testing
Functional Testing
• This is a type of black-box testing that is based on the specifications
of the software that is to be tested.
• The application is tested by providing input and then the results are
examined that need to confirm to the functionality it was intended
for.
• Functional testing of a software is conducted on a complete,
integrated system to evaluate the system's compliance with its
specified requirements.
• There are four main types of functional testing.
• There are five steps that are involved while testing an
application for functionality.
III The output based on the test data and the specifications of the application.
V The comparison of actual and expected results based on the executed test
cases.
[Link] Testing
• Unit testing is a type of software testing which is done on an individual unit or
component to test its corrections.
• Typically, Unit testing is done by the developer at the application development
phase.
• Each unit in unit testing can be viewed as a method, function, procedure, or
object.
• Developers often use test automation tools such as NUnit, Xunit, JUnit for the
test execution.
• Unit testing is important because we can find more defects at the unit test
level.
• For example, there is a simple calculator application. The developer can write
the unit test to check if the user can enter two numbers and get the correct
sum for addition functionality.
[Link] Testing
• a) White Box Testing
• White box testing is a test technique in which the internal structure or code of
an application is visible and accessible to the tester.
• In this technique, it is easy to find loopholes in the design of an application or
fault in business logic.
• Statement coverage and decision coverage/branch coverage are examples of
white box test techniques.
• b) Gorilla Testing
• Gorilla testing is a test technique in which the tester and/or developer test the
module of the application thoroughly in all aspects.
• Gorilla testing is done to check how robust your application is.
Unit Testing (White Box)
• Individual components are tested.
• It is a path test.
• To focus on a relatively small segment of code and aim to
exercise a high percentage of the internal path
• Disadvantage: the tester may be biased by previous
experience. And the test value may not cover all possible
values.
2) Integration Testing
• Integration testing is a type of software testing where two or more modules
of an application are logically grouped together and tested as a whole.
• The focus of this type of testing is to find the defect on interface,
communication, and data flow among modules.
• Top-down or Bottom-up approach is used while integrating modules into the
whole system.
• This type of testing is done on integrating modules of a system or between
systems.
• For example, a user is buying a flight ticket from any airline website. Users
can see flight details and payment information while buying a ticket, but
flight details and payment processing are two different systems. Integration
testing should be done while integrating of airline website and payment
processing system.
Integration Testing
• Top-down Integration Test
• Bottom-up Integration Test
Top-down Integration Test
• The control program is tested first. Modules are integrated one
at a time. Emphasize on interface testing
• Advantages: No test drivers needed
Interface errors are discovered early
Modular features aid debugging
• Disadvantages: Test stubs are needed
Errors in critical modules at low levels are found late.
Bottom-up Integration Test
• Allow early testing aimed at proving feasibility
Emphasize on module functionality and performance
• Advantages: No test stubs are needed
Errors in critical modules are found early
• Disadvantages: Test drivers are needed
Interface errors are discovered late
Bottom-up testing
Test Test
Drivers Drivers
• The main idea of usability testing of this kind of app is that as soon as
the user opens the app, the user should get a glance at the market.
• a) Exploratory testing