SE401 - Software Quality Assurance and Testing
SE401 - Software Quality Assurance and Testing
SE401 - Software Quality Assurance and Testing
and Testing
Introduction
Thought for the Day
Software Testing takes at least twice as long as estimated.
Software is Everywhere
Outlines
College of Computer and Information Systems - Prince Sultan University These slides are prepared from: https://www.guru99.com/software-testing.html and Software Testing and Analysis: 4
Process, Principles and Techniques (2008)
What is Software Testing?
College of Computer and Information Systems - Prince Sultan University These slides are prepared from: https://www.guru99.com/software-testing.html and 5
Software Testing and Analysis: Process, Principles and Techniques (2008)
Why Software Testing is Important?
▪ China Airlines Airbus A300
Crashed due to a software bug on April 26, 1994, killing 264 innocent live
College of Computer and Information Systems - Prince Sultan University These slides are prepared from: https://www.guru99.com/software-testing.html and 6
Software Testing and Analysis: Process, Principles and Techniques (2008)
Why Software Testing is Important?
▪ Canada's Therac-25 radiation therapy machine
Malfunctioned in 1985 due to software bug and delivered lethal radiation doses to
patients, leaving 3 people dead and critically injuring 3 others.
College of Computer and Information Systems - Prince Sultan University These slides are prepared from: https://www.guru99.com/software-testing.html and 7
Software Testing and Analysis: Process, Principles and Techniques (2008)
Why Software Testing is Important?
▪ $1.2 billion military satellite launch
Failed In April of 1999 because of a software bug. The costliest accident in history
College of Computer and Information Systems - Prince Sultan University These slides are prepared from: https://www.guru99.com/software-testing.html and 8
Software Testing and Analysis: Process, Principles and Techniques (2008)
Why Software Testing is Important?
▪ US Bank Accounts
College of Computer and Information Systems - Prince Sultan University These slides are prepared from: https://www.guru99.com/software-testing.html and 9
Software Testing and Analysis: Process, Principles and Techniques (2008)
Economic Impact
▪ NIST, “The Economic Impacts of Inadequate Infrastructure for
Software Testing”
− Inadequate software testing costs the US alone around $59.5
billion annually
− Better approaches could cut this amount by $22.2 billion
▪ We want our programs to be reliable
− Testing is how, in most cases, we find out if they are
Launch of MS Windows 98
▪ Bill Gates and Blue Screen of Death
Launch of MS Windows 98
▪ Bill Gates and Blue Screen of Death
A Case Study: Ariane 5 Launch Vehicle
▪ European expendable launch system
▪ Double the payload capacity of its
predecessor Ariane 4
− 113 successful launches, 3 failures
▪ Flight 501, maiden launch,
June 4, 1996,12:34pm
Case Study Ariane 5: Why Did It Happen?
▪ Not a programming error
− unprotected conversion = design decision (~1980)
▪ Not a design error
− Justified against Ariane 4 trajectory & RT constraints
▪ Problem with integration testing
− Theoretically detectable.
− But huge test space vs. limited resources
− Furthermore, Inertial Reference System (SRI) useless at this stage of the flight!
▪ Reuse of a component with a hidden constraint
− Precondition : abs(BH) < 32768.0
− Valid for Ariane 4, but no longer for Ariane 5
o More powerful rocket
Case Study Ariane 5:
Lessons Learned in Software Eng.
▪ Test! Test! Test!
▪ Test! Even when the code is reused.
▪ When reuse, ensure the assumptions are still valid.
▪ When write reusable code, document the assumptions.
▪ Write fail-safe code.
▪ Do not propagate errors.
Why Software Testing is Important?
College of Computer and Information Systems - Prince Sultan University These slides are prepared from: https://www.guru99.com/software-testing.html and 17
Software Testing and Analysis: Process, Principles and Techniques (2008)
Why Programs fail
▪ In Federalist 51, James Madison wrote: “If men were angels, no
government would be necessary.”
▪ If he lived today, Madison might have written: “If software
developers were angels, debugging would be unnecessary.”
Why Programs fail
Congratulations!
▪ Your code is complete. It compiles. It runs …
▪ Your program fails. How can this be?
▪ There is a defect in the code. When the code is executed, the defect causes bad behavior, which
later becomes visible as a failure.
▪ Before a program can be debugged, we must set it up such that it can be tested — that is,
executed with the intent to make it fail.
▪ The first step in debugging is to reproduce the problem in question — that is, to create a test case
that causes the program to fail in the specified way.
− The first reason is to bring it under control, such that it can be observed.
− The second reason is to verify the success of the fix.
▪ Now you will have the fun of testing and debugging!
Why Do We Test?
▪ Testing is expensive.
− So are failures!
▪ What do we gain from that cost?
− Finding bugs
− Leading to
o Fixing bugs
o Raising the quality of the program or system we are testing
Trade-Offs of Cost and Failures
Total Cost of Quality (CoQ) =
Cost of Conformance (CoC) +
Cost of Non-Conformance (CoNC)
▪ Cost of Conformance
− Prevention: quality planning, investment in tools, quality training
− Appraisal: testing, inspection
▪ Cost of Non-Conformance
− Internal failures: rework
− External failure: liability, loss of properties, loss of lives
Trade-Offs of Cost and Failures
▪ Testing adds to Cost of Conformance
▪ It must directly reduce Cost of Non-Conformance
Software Testing
Myths and Facts
Myth #1 in Software Testing
Fact:
No!! The main objective of testing is to discover defects.
Testing is a destructive activity.
Myth #2 in Software Testing
Fact:
Only partly true.
Testing is also to ensure the software does not do what it is not supposed
to do.
Myth #3 in Software Testing
Write a set of test cases that you feel would adequately test this
program.
How Will You Do It?
Write a set of test cases that you feel would adequately test this
program.
▪ How many cases are needed?
▪ How do you plan to test the program?
− Run it once and manually enter the values?
− Run it many times with different inputs?
− Run it with a file containing a set of lines with test values?
How will you do it?
▪ “Smoke test.”, aka “Hello World!”
▪ Check handling of inputs
− Illegal inputs – text instead of integers
− Impossible inputs – floating vs. integer
− Outrageous values – infinities, max and min values
− Not in domain – negative numbers,
values outside specifications
− Input errors – wrong input, e.g. mis-spellings
▪ Stress test
− multiple inputs without restart
− run program for long periods of time
Software Testing
Terminologies
The Very First Software Bug
On display in Smithsonian
Failures
▪ Failures are
− deviation of the observed behavior of a system from its
specification, i.e., its expected behavior.
▪ Failures can only be determined with respect to the
specifications.
▪ Failures are concerned with the observed behavior
and outcome of the system.
Defects
▪ Defects are
− flaws in a system that can cause the system to fail to
perform its required function
oe.g. an incorrect condition or statement.
▪ Errors are
− human actions that result in a fault or defect in the
system.
▪ Errors are concerned with the underlying causes of
the defects.
▪ Errors are synonymous with mistakes.
The Relations among Failures, Defects, and Errors
A defect A failure
College of Computer and Information Systems - Prince Sultan University These slides are prepared from: https://www.guru99.com/software-testing.html and 40
Software Testing and Analysis: Process, Principles and Techniques (2008)
Failures, Defects, and Errors
▪ An example: For any integer n, square (n) = n*n.
• Input values
• Sometimes include execution steps
• Expected outputs
int actual_output=sum(1,2)
assertTrue(actual_output==3);
Example JUnit test case for testing “sum(int a, int b)”
Testing: Concepts
• Test oracle
• The expected outputs of software for given input
• A part of test cases
• Hardest problem in auto-testing: test oracle generation
int actual_output=sum(1,2)
assertTrue(actual_output==3);
Example JUnit test case for testing “sum(int a, int b)”
Testing: Concepts
• Test fixture: a fixed state of the software under test used as a baseline for
running tests; also known as the test context, e.g.,
• Test suite
• A collection of test cases
• Usually these test cases share similar pre-requisites and configuration
Usually can be run together in sequence
•
Different test suites for different purposes
•Certain platforms, Certain feature, performance, …
• Test Script
• A script to run a sequence of test cases or a test suite automatically
Testing: Concepts
• Test driver
• A software framework that can load a collection of test cases or a test
suite
• It can also handle the configuration and comparison between
expected outputs and actual outputs
Testing: Concepts
▪Test adequacy
− We can’t always use all test inputs, so which do we use and when do we stop?
− We need a strategy to determine when we have done enough
− Adequacy criterion: A rule that lets us judge the sufficiency of a set of test data
for a piece of software
Testing: Concepts
• Statement coverage
• Branch coverage, ...
Cobertura tool
Test Plan and Testing Process
▪ Test plan
− A document that specifies how a system will be tested,
including criteria for success, i.e., the exit criteria.
▪ Testing process
− The testing process involves developing test plans,
designing test cases, running the test cases, and
evaluating the results
Granularity of Testing
▪ Automated Testing
▪ Testing Types − Pros and cons
− Black-box
− White-box ▪ Defect tracking
Ad Hoc Testing
▪ Ad hoc testing
− Testing carried out informally
− No formal test preparation
− No recognized test design technique is used
− Expected results not defined
− Arbitrariness guides the test execution activity
College of Computer and Information Systems - Prince Sultan University These slides are prepared from: https://www.guru99.com/software-testing.html and 63
Software Testing and Analysis: Process, Principles and Techniques (2008)
Categories of Software Testing
Testing Category Types of Testing (examples)
College of Computer and Information Systems - Prince Sultan University These slides are prepared from: https://www.guru99.com/software-testing.html and 68
Software Testing and Analysis: Process, Principles and Techniques (2008)
Testing shows presence of defects
College of Computer and Information Systems - Prince Sultan University These slides are prepared from: https://www.guru99.com/software-testing.html and 70
Software Testing and Analysis: Process, Principles and Techniques (2008)
Exhaustive Testing is not possible
loop < 20 iterations
College of Computer and Information Systems - Prince Sultan University These slides are prepared from: https://www.guru99.com/software-testing.html and 73
Software Testing and Analysis: Process, Principles and Techniques (2008)
Pesticide Paradox
▪ If the same set of repetitive tests are conducted, the method will be
useless for discovering new defects.
▪ To overcome this, the test cases need to be regularly reviewed &
revised, adding new & different test cases to help find more defects.
▪ Testers cannot simply depend on existing test techniques. They must
aim continually to improve the existing methods to make testing
more effective.
▪ But even after all this testing, you can never claim your product is bug
free.
College of Computer and Information Systems - Prince Sultan University These slides are prepared from: https://www.guru99.com/software-testing.html and 74
Software Testing and Analysis: Process, Principles and Techniques (2008)
Testing is basically context-dependent
▪ Various products or projects contain different elements, features, and
requirements.
− Hence, testers cannot apply the same test approach for different
projects. For instance, an application in banking industry should require
different testing techniques than an entertainment software.
75
College of Computer and Information Systems - Prince Sultan University These slides are prepared from: https://www.guru99.com/software-testing.html and Software
Testing and Analysis: Process, Principles and Techniques (2008)
The absence of Errors Fallacy
Actual output
Expected output
Test the Invalid and Unexpected
▪ Tools Used
− Test script
− Automated compilation, build and testing: Ant
− Automated running of tests: JUnit
− Debugging: Eclipse debugger
− Code Coverage: Cobertura, EclEmma, JaCoCo
Fundamental Principles Myth
▪ Myth: "Principles are just for reference. I will not use them in
practice .“
▪ Fact:
− This is so very untrue. Test Principles will help you create an effective Test
Strategy and draft error catching test cases.
− Experienced testers have internalized these principles to a level that they apply
them without even thinking.
− Hence the myth that the principles are not used in practice is simply not true.
College of Computer and Information Systems - Prince Sultan University These slides are prepared from: https://www.guru99.com/software-testing.html and 82
Software Testing and Analysis: Process, Principles and Techniques (2008)
Limitations of
Software Testing
Exhaustive Testing
loop < 20 iterations
College of Computer and Information Systems - Prince Sultan University These slides are prepared from: https://www.guru99.com/software-testing.html and 89
Software Testing and Analysis: Process, Principles and Techniques (2008)
Cost of Fixing Defects across the SDLC
▪ The costs of fixing a defect
increases across the
development life cycle. The
earlier in life cycle a defect is
detected, the cheaper it is to fix it.
▪ To address this concern, the V
model of testing was developed
where, for every phase in the
Development life cycle, there is a
corresponding Testing phase
College of Computer and Information Systems - Prince Sultan University These slides are prepared from: https://www.guru99.com/software-testing.html and 90
Software Testing and Analysis: Process, Principles and Techniques (2008)
V-Model of Testing
▪ The left side of the model is
Software Development Life
Cycle - SDLC
▪ The right side of the model is
Software Test Life Cycle
- STLC
▪ The entire figure looks like a V,
hence the name V – model
▪ Achieves the principle “Early
Testing”
College of Computer and Information Systems - Prince Sultan University These slides are prepared from: https://www.guru99.com/software-testing.html and 91
Software Testing and Analysis: Process, Principles and Techniques (2008)
Other Development Models
planning
estimation
scheduling
risk analysis
communication
modeling
analysis
design
start
deployment
construction
delivery
code
feedback test
College of Computer and Information Systems - Prince Sultan University These slides are prepared from: https://www.guru99.com/software-testing.html and 92
Software Testing and Analysis: Process, Principles and Techniques (2008)
Other Development Models
College of Computer and Information Systems - Prince Sultan University These slides are prepared from: https://www.guru99.com/software-testing.html and 93
Software Testing and Analysis: Process, Principles and Techniques (2008)
SDLC and Testing
▪ It is important to understand that there are various development
life cycle models.
− Selecting a development model for a project depends on the aims and goals of
that project.