Software testing fundamentals-Internal and external views of Testing-white box testing - basis path testing-control structure testing-black box testing- Regression Testing – Unit Testing – Integration Testing – Validation Testing – System Testing and Debugging –Software Implementation Tech...
Software testing fundamentals-Internal and external views of Testing-white box testing - basis path testing-control structure testing-black box testing- Regression Testing – Unit Testing – Integration Testing – Validation Testing – System Testing and Debugging –Software Implementation Techniques: Coding practices-Refactoring-Maintenance and Reengineering-BPR model-Reengineering process model-Reverse and Forward Engineering – Software Configuration Management.
Size: 2.88 MB
Language: en
Added: May 20, 2024
Slides: 116 pages
Slide Content
1
Software Engineering
KCS-601, Unit-IV
Dr APJ Abdul KalamTechnical
University, Lucknow
By
Dr AnuranjanMisraDr AnuranjanMisra
innovation
Ambassador
Ministry of Education,
Government of India
& Professor & Dean,
GNIOT, Greater
Noida
Testing Objectives
•
Testing is the process of executing a program
with the intent of finding errors.
•
A good test case is one with a high probability of
finding an as-yet undiscovered error.finding an as-yet undiscovered error.
•
A successful test is one that discovers an as-yet-
undiscovered error.
Testing Principles
•
All tests should be traceable to customer
requirements.
•
Tests should be planned before testing begins.
•
80% of all errors are in 20% of the code.
•
Testing should begin in the small and progress to
the large.
•
Exhaustive testing is not possiblefor real
programs due to combinatorial explosion of
possible test cases
•
Testing should be conducted by an independent
third party if possible.
Debugging vs. Testing
•
Debuggingis the process of finding errors in a
program under development that is not thought to
be correct.
•
Testingis the process of attempting to find errors
in a program that is thought to be correct.in a program that is thought to be correct.
•
Testing attempts to establish that a program
satisfies its specifications.
•
Testing can establish the presence of errors
but cannot guarantee for their absence.
•
Amount of testing performed must be balanced
against the cost of undiscovered errors.
Verification and Validation
•
The distinction between the two terms is largely
to do with the role of specifications.
•
Validationis the process of checking whether the
specification captures the customer's needs. That
is, Specifications are as per customer is, Specifications are as per customer
requirements/needs.
•
Whereas, verificationis the process of checking
that the software meets the specification. That is,
software is as per specifications.
•
Testing = Validation + Verification
SOFTWARE TESTING FUNDAMENTALS
What is Testing?
•
Testingisaprocessofexercisingsoftwaretoverifythatit
satisfiesspecifiedrequirementsandtodetecterrors.
•
Softwaretestingisaprocessofexecutingaprogramor
•
Softwaretestingisaprocessofexecutingaprogramor
applicationwiththeintentoffindingthesoftwarebugs.
•
Itcanalsobestatedastheprocessofvalidatingand
verifyingthatasoftwareprogramorapplicationor
product:
1. Meets the business and technical requirements
that guided it’s design and development
2. Works as expected
3. Can be implemented with the same characteristic.
What is an error in software testing?
•
The mistake made by programmer is known as an ‘Error’.
This could happen because of the following reasons:
•
Because of some confusion in understanding the
functionality of the software
•
Because of some miscalculation of the values
•
Because of misinterpretation of any value, etc.
What is a Failure in software testing?
•
Ifundercertaincircumstancesthesedefectsgetexecuted
bythetesterduringthetestingthenitresultsintothe
failurewhichisknownassoftwarefailure.
•
Notalldefectsresultinfailures,somemaystayinactivein
thecodeandwemaynevernoticethem.Example:thecodeandwemaynevernoticethem.Example:
Defectsindeadcodewillneverresultinfailures.
Error: Human mistake that caused fault
Fault: Discrepancy in code that causes a failure.
Failure: External behavior is incorrect
Test Characteristics
Kaner, Falk, and Nguyen [Kan93] suggest the following
attributes of a ―good‖ test:
•
A good test has a high probability of finding an error
•
A good test is not redundant
•
A good test should be ―best of breed‖
•
A good test should be neither too simple nor too complex
What are the principles of testing?
There are seven principles of testing. They are as follows:
1) Testing shows presence of defects:
2) Exhaustive testing is impossible
3) Early testing: 3) Early testing:
4) Pesticide paradox
5) Testing is context depending
6) Testing is context depending
7) Absence –of –errors fallacy
Software Testing Strategy
Unit testing :Code
Integration testing : Design Integration testing : Design
Validation test : Requirements
System test : System engineering architecture
INTERNAL AND EXTERNAL VIEWS OF TESTING
Testing is done by two methods
1. Black box testing
2. White box testing
Black-boxtestingalludestoteststhatareconductedattheBlack-boxtestingalludestoteststhatareconductedatthe
softwareinterface.Ablack-boxtestexaminessome
fundamentalaspectofasystemwithlittleregardforthe
internallogicalstructureofthesoftware.
White-boxtestingofsoftwareispredicatedonclose
examinationofproceduraldetail.Logicalpathsthroughthe
softwareandcollaborationsbetweencomponentsare
testedbyexercisingspecificsetsofconditionsand/orloops.
This method attempts to find errors in the
following categories:
•
Incorrect or missing functions
•
Interface errors
•
Errors in data structures or external database
•
Errors in data structures or external database
access
•
Behavior or performance errors
•
Initialization and termination errors
Advantages
•
The test is unbiased because the designer and the tester are
independent of each other.
•
The tester does not need knowledge of any specific
programming languages.
•
The test is done from the point of view of the user, not the
designer.
•
Test cases can be designed as soon as the specifications are
complete. complete.
Disadvantages
•
The test can be redundant if the software designer has already
run a test case.
•
The test cases are difficult to design.
•
Testing every possible input stream is unrealistic because it
would take a inordinate amount of time; therefore, many
program paths will go untested.
White box testing involves the testing of the software
code for the following:
•
Internal security holes
•
Broken or poorly structured paths in the coding
processes
•
The flow of specific inputs through the code
•
Expected output
•
The functionality of conditional loops
•
Testing of each statement, object and function on
an individual basis
Data Flow Testing
The data flow testing method selects test paths of a
program according to the locations of definitions and uses
of variables in the program.
For a statement with S as its statement number,
DEF(S) = {X | statement S contains a definition of X}
USE(S) = {X | statement S contains a use of X}
Classes of Loops
Simple loops. The following set of tests can be applied to
simple loops, where n is the maximum number of allowable
passes through the loop.
1. Skip the loop entirely. 1. Skip the loop entirely.
2. Only one pass through the loop.
3. Two passes through the loop.
4. m passes through the loop where m < n.
5. n -1, n, n + 1 passes through the loop.
Nested loops
Beizer suggests an approach that will help to reduce the
number of tests:
1.Startattheinnermostloop.Setallotherloopsto
minimumvalues.
2.Conductsimplelooptestsfortheinnermostloopwhile2.Conductsimplelooptestsfortheinnermostloopwhile
holdingtheouterloopsattheirminimumiteration
parameter(e.g.,loopcounter)values.Addothertestsfor
out-of-rangeorexcludedvalues.
3.Workoutward,conductingtestsforthenextloop,but
keepingallotherouterloopsatminimumvaluesandother
nestedloopsto―typicalvalues.
4.Continueuntilallloopshavebeentested.
Concatenated loops
Concatenated loops can be tested using the approach
defined for simple loops, if each of the loops is independent
of the other.
Unstructured loops Unstructured loops
Classofloopsshouldberedesignedtoreflecttheuseof
thestructuredprogrammingconstructs.
Concatenated loops
Concatenated loops can be tested using the approach
defined for simple loops, if each of the loops is independent
of the other.
Unstructured loops Unstructured loops
Classofloopsshouldberedesignedtoreflecttheuseof
thestructuredprogrammingconstructs.
Types of Black box testing:
•
Random Testing
•
Equivalence class partitioning
•
Boundary value analysis
•
Graph based testing
•
Orthogonal array testing
Random Testing
Randomtestingisablack-boxsoftwaretestingtechnique
whereprogramsaretestedbygeneratingrandom,
independentinputs.
Resultsoftheoutputarecomparedagainstsoftware
specificationstoverifythatthetestoutputispassorfail.
•
It eliminates exhaustive testing.
•
It eliminates exhaustive testing.
•
Random testing can save time and effort.
•
Breadth-first integration incorporates all components
directly subordinate at each level, moving across the
structure horizontally.
•
The integration process is performed in a series of five
steps:
Integration test approaches
There are four types of integration testing approaches.
Those approaches are the following
1. Big-Bang Integration Testing
Itisthesimplestintegrationtestingapproach,whereallthe
modulesarecombiningandverifyingthefunctionalityaftermodulesarecombiningandverifyingthefunctionalityafter
thecompletionofindividualmoduletesting.Insimple
words,allthemodulesofthesystemaresimplyput
togetherandtested.Thisapproachispracticableonlyfor
verysmallsystems.Ifonceanerrorisfoundduringthe
integrationtesting,itisverydifficulttolocalizetheerroras
theerrormaypotentiallybelongtoanyofthemodules
beingintegrated.So,debuggingerrorsreportedduringbig
bangintegrationtestingareveryexpensivetofix.
Software validation is achieved through a series of tests that
demonstrate conformity with requirements.
•
Atestplanoutlinestheclassesofteststobeconducted,anda
testproceduredefinesspecifictestcasesthataredesignedto
ensurethatallfunctionalrequirementsaresatisfied,all
behavioralcharacteristicsareachieved,allcontentisaccurate
andproperlypresented,allperformancerequirementsare
attained,documentationiscorrect,andusabilityandotherattained,documentationiscorrect,andusabilityandother
requirementsaremet(e.g.,trans-portability,compatibility,error
recovery,maintainability).
•
Aftereachvalidationtestcasehasbeenconducted,oneoftwo
possibleconditionsexists:(1)Thefunctionorperformance
characteristicconformstospecificationandisacceptedor(2)a
deviationfromspecificationisuncoveredandadeficiencylistis
created.Deviationsorerrorsdiscoveredatthisstageinaproject
canrarelybecorrectedpriortoscheduleddelivery.
SYSTEM TESTING
System testing is actually a series of different tests whose
primary purpose is to fully exercise the computer-based
system.
Various types of system tests are
•
Recovery Testing
•
Security Testing
•
Stress Testing
•
Performance Testing
•
Deployment Testing
Debugging Strategies
In general, three debugging strategies have been proposed
(1) brute force,
(2) backtracking, and
(3) cause elimination.
•
Each of these strategies can be conducted manually, but
modern debugging tools can make the process much modern debugging tools can make the process much
more effective.
Debugging tactics.
•
The brute force category of debugging is probably the
most common and least efficient method for isolating the
cause of a software error.
Correcting the Error
Once a bug has been found, it must be corrected.
Van Vleck suggests three simple questions that you should
ask before making the ―correction‖ that removes the
cause of a bug:
•
Is the cause of the bug reproduced in another part of the
•
Is the cause of the bug reproduced in another part of the
program?
•
What ―next bug‖ might be introduced by the fix I‘m about
to make?
•
What could we have done to prevent this bug in the first
place?
Correcting the Error
Once a bug has been found, it must be corrected.
Van Vleck suggests three simple questions that you should
ask before making the ―correction‖ that removes the
cause of a bug:
•
Is the cause of the bug reproduced in another part of the
•
Is the cause of the bug reproduced in another part of the
program?
•
What ―next bug‖ might be introduced by the fix I‘m about
to make?
•
What could we have done to prevent this bug in the first
place?
Software Implementation Techniques
Afterdetailedsystemdesignwegetasystemdesignwhichcanbe
transformedintoimplementationmodel.Thegoalcodingisto
implementthedesigninthebestpossiblemanner.Codingaffectsboth
testingandmaintenanceverydeeply.Thecodingshouldbedonein.
suchamannerthattheinsteadofgettingthejobofprogrammer
simplifiedthetaskoftestingandmaintenancephaseshouldget
simplified.
Various objectives of coding are –Various objectives of coding are –
1. Programs developed in coding should be readable.
2. They should execute efficiently.
3. The program should utilize less amount of memory.
4. The programs should not be lengthy
If the objectives are clearly specified before the programmers then
while coding they try to achieve the specified objectives. To achieve
these objectives some programming principles must be followed.
Coding Practices
There are some commonly used programming practices that help in
avoiding the common errors. These are enlisted below –
1. Control construct
The single entry and single exit constructs need to be used. The
standard control constructs must be used instead of using wide variety
of controls.
2. Use of gotos
Thegotostatementsmaketheprogramunstructuredanditalso
imposesoverheadoncompilationprocess.Henceavoiduseofgoto
statementsasfaraspossibleandanotheralternativemustbethought
of.
3. Information hiding
Informationhidingshouldbesupportedasfaraspossible.Inthatcase
onlyaccessfunctionstothedatastructuresmustbemadevisibleand
theinformationpresentinitmustbehidden.
Coding Standards
Any good software development approach suggests to adhere to
some well-defined standards or rules for coding. These rules are
called coding standards.
1. Naming Conventions
1.
Followingaresomecommonlyusednamingconventionsinthe
coding
2.
Packagenameandvariablenamesshouldbeinlowercase.
3.
Variablenamesmustnotbeginwithnumbers.
3.
Variablenamesmustnotbeginwithnumbers.
4.
Thetypenameshouldbenounanditshouldstartwithcapital
letter.
5.
Constantsmustbeinuppercase(ForexamplePI,SIZE)
6.
Methodnamemustbegiveninlowercase.
7.
Thevariableswithlargescopemusthavelongname.For
examplecount_total,sum,Variableswithshortscopemust
haveshortname.Forexamplei,j.
8.
TheprefixismustbeusedforBooleantypeofvariables.For
exampleisEmptyorisFull
There are two general categories of benefits to the activity of
refactoring.
1.
Maintainability.Itiseasiertofixbugsbecausethe
sourcecodeiseasytoreadandtheintentofitsauthoris
easytograsp.Thismightbeachievedbyreducinglarge
monolithicroutinesintoasetofindividuallyconcise,well-
named,single-purposemethods.Itmightbeachievedbynamed,single-purposemethods.Itmightbeachievedby
movingamethodtoamoreappropriateclass,orby
removingmisleadingcomments.
2.Extensibility.Itiseasiertoextendthecapabilitiesofthe
applicationifitusesrecognizabledesignpatterns,andit
providessomeflexibilitywherenonebeforemayhave
existed.
Refactoring is needed due to various reasons. They are as follows:
•
LackofModularity–Existingfeatureofoneapplicationcan’tbe
usedinanotherapplicationduetoitstightcouplingwiththe
applicationcomponents.
•
LackofReusableComponents –Thereareinstancesofcode
duplicityandpotentialreusablecomponentsdependencyon
applicationcode.
•
LackofPluggableComponents–Existingcomponentsarenot
•
LackofPluggableComponents–Existingcomponentsarenot
easilyreplaceableduetoitsapplicationcodetightlycoupledwith
thecomponents.
•
Service Oriented Architecture –Scope for SOA components
where each component can work as a service and reusable.
•
Code Redundancy –Application has lots of dead code and
duplicate code.
•
Lack of Layered Architecture –Any change in one layer causes
changes in all other layers.
Perfective maintenance
•
Users and marketers are never satisfied
•
Even if a system is wildly successful, someone will want
new or enhanced features added to it
•
Sometimes there will also be impetus to alter the way a
certain component of the system works, or its interface certain component of the system works, or its interface
•
The process of receiving suggestions and requests for such
enhancements or modifications, evaluating
Reengineering:
•
The process typically encompasses a combination of other processes
such as reverse engineering, re-documentation, restructuring, translation,
and forward engineering.
•
For example, initially Unix was developed in assembly language. When
language C came into existence, Unix was re-engineered in C, because
working in assembly language was difficult.
•
Other than this, sometimes programmers notice that few parts of
software need more maintenance than others and they also need re-
engineering. engineering.
Business Process Reengineering (BPR)
Alsoknownasprocessinnovationandcoreprocessredesign-
attemptstorestructureorobliterateunproductivemanagement
layers,wipeoutredundancies,andremodelprocesses
differently.Businessprocessre-engineeringreferstothe
analysis,controlanddevelopmentofacompany’ssystemsand
workflow
Re-Engineering Process
•
Decide what to re-engineer. Is it whole software or a part of
it?
•
Perform Reverse Engineering, in order to obtain
specifications of existing software.
•
Restructure Program if required. For example, changing
function-oriented programs into object-oriented programs. function-oriented programs into object-oriented programs.
•
Re-structure data as required.
•
Apply Forward engineering concepts in order to get re-
engineered software.
.
Reengineering process model .
Code restructuring
•
Source code is analyzed and violations of structured
programming practices are noted and repaired
•
Revised code needs to be reviewed and tested
Data restructuring Data restructuring
•
Usually requires full reverse engineering
•
Current data architecture is dissected
•
Data models are defined
•
Existing data structures are reviewed for quality
Software Reviews
•
A review is any activity in which a work product is
exposed to reviewers to examine and give
feedback.
•
Purpose is to find defects (errors) before they are
passed on to another software engineering passed on to another software engineering
activity or released to the customer.
•
Software engineers (and others) conduct formal
technical reviews (FTR)
•
Using formal technical reviews is an effective
means for improving software quality.
Review Roles
•
Presenter (designer/producer).
•
Coordinator
•
Recorder
•
records events of meeting
•
records events of meeting
•
builds paper trail
•
Reviewers
•
maintenance experts
•
standards bearer
•
user representative
•
others
Formal Technical Reviews
•
Involves 3 to 5 people (including reviewers)
•
Advance preparation (no more than 2 hours per
person) required
•
Duration of review meeting should be less than 2
•
Duration of review meeting should be less than 2
hours
•
Focus of review is on a discrete work product
•
Review leader organizes the review meeting at
the producer's request.
Formal Technical Reviews
•
Reviewers ask questions that enable the producer to
discover his or her own error (the product is under
review not the producer)
•
Producer of the work product walks the reviewers
through the productthrough the product
•
Recorder writes down any significant issues raised
during the review
•
Reviewers decide to accept or reject the work product
or to go for additional reviews of the product.
All work products and components like SRS, schedules,
design documents, code, test plans, test cases, and
defect reports should be reviewed.
Why Reviews?
•
To improve the quality.
•
Catch 80% of all errors if done properly.
•
Catch both coding and design errors.
•
Enforce the spirit of any organization standards.
•
Training and insurance.
•
Training and insurance.
•
Useful not only for finding and eliminating defects, but
also for gaining consensus among the project team,
securing approval from stakeholders, and aiding in
professional development for team members.
•
Help find defects soon after they are injected making
them cost less to fix than they would cost if they were
found in test.
Types of Review:
Inspections
•
Inspectionsare moderated meetings in which
reviewers list all issues and defects they have
found in the document and log them so that they
can be addressed by the author.can be addressed by the author.
•
The goal of the inspection is to repair the defects
so that everyone on the inspection team can
approve the work product.
•
Commonly inspected work products include
software requirements specifications and test
plans.
Types of Review:
Inspections
•
Running an inspection meeting:
1.
A work product is selected for review and a team is gathered
for an inspection meeting to review the work product.
2.
A moderator is chosen to moderate the meeting.
3.
Each inspector prepares for the meeting by reading the work
product and noting each defect.product and noting each defect.
4.
In an inspection, a defect is any part of the work product that
will keep an inspector from approving it.
5.
Discussion is focused on each defect, and coming up with a
specific resolution.
•
Job of the inspection team is not just identify the problems;
but also come up with the solutions.
6.
The moderator compiles all of the defect resolutions into an
inspection log
Inspection Log Example
Types of Review:
Deskchecks
•
A deskcheckis a simple review in which the
author of a work product distributes it to one
or more reviewers.
The author sends a copy of the work product
•
The author sends a copy of the work product
to selected project team members. The team
members read it, and then write up defects
and comments to send back to the author.
Types of Review:
Deskchecks
•
Unlike an inspection, a deskcheckdoes not
produce written logs which can be archived with
the document for later reference.
•
Deskcheckscan be used as predecessors to
•
Deskcheckscan be used as predecessors to
inspections.
•
In many cases, having an author of a work
product pass his work to a peer for an informal
review will significantly reduce the amount of effort
involved in the inspection.
Types of Review:
Walkthroughs
•
A walkthrough is an informal way of presenting a
technical document in a meeting.
•
Unlike other kinds of reviews, the author runs the
walkthrough: calling the meeting, inviting the
reviewers, soliciting comments and ensuring that reviewers, soliciting comments and ensuring that
everyone present understands the work product.
•
After the meeting, the author should follow up with
individual attendees who may have had additional
information or insights.
•
The document should then be corrected to reflect
any issues that were raised.
Types of Review:
Code Review
•
A code review is a special kind of inspection in which
the team examines a sample of code and fixes any
defects in it.
•
In a code review, a defect is a block of code
•
which does not properly implement its requirements.
•
which does not function as the programmer intended.
•
which is not incorrect but could be improved . For
example, it could be made more readable or its
performance could be improved
Types of Review:
Code Review
•
It’s important to review the code which is most
likely to have defects.
•
Good candidates for code review include:
•
A portion of the software that only one person has the
expertise to maintain.expertise to maintain.
•
Code that implements a highly abstract or tricky algorithm
•
An object, library or API that is particularly difficult to work
with.
•
Code written by inexperienced persons, or entirely new type
of code, or code written in an unfamiliar language
•
Code which employs a new programming technique
•
An area of the code that will be especially catastrophic if there
are defects
Types of Review:
Pair Programming
•
Pair programming is a technique in which two
programmers work simultaneously at a single
computer and continuously review each others’
work.
Although many programmers were introduced to
•
Although many programmers were introduced to
pair programming, it is a practice that can be
valuable in any development environment.
•
Pair programming improves the organization by
ensuring that at least two programmers are able to
maintain any piece of the software.
Types of Review:
Pair Programming
•
Pair programming works best if the pairs are
constantly rotated. Prefer to pair a junior person
with a senior for knowledge sharing.
•
The project manager should not try to force pair
programming on the team; it helps to introduce the programming on the team; it helps to introduce the
change slowly, and where it will meet the least
resistance.
•
It is difficult to implement pair programming in an
organization where programmers do not share the
same nine-to-five work schedule.
•
Some people do not work well in pairs, and some
pairs do not work well together.
Relative Cost of Defect Removal
Relative Cost of Defect Removal
Defect Amplification Model
Defect Prevention/ Removal
•
S/w contains 200K lines
•
Inspection time = 7053 Hrs.
•
Defects prevented = 3112
•
Programmer cost = 40.00 per hr.
•
Total cost of defect prevention = 7053 x 40.00
•
Total cost of defect prevention = 7053 x 40.00
= 282120.00
•
Cost per defect prevention = 2120/3112
= 91.00
Defect Removal
•
Defect escaped into product = 1 per 1K
•
Total defects escaped = 200K/1000
= 200
Cost of removal of single defect = 25000
•
Cost of removal of single defect = 25000
•
Total defect removal cost = 25000 x 200
= 5000000
•
Ratio of defect removal to prevention = 18
Formality and Timing
•
Formal review presentations
•
resemble conference presentations.
•
Informal presentations
•
less detailed, but equally correct.less detailed, but equally correct.
•
Early Reviews
•
tend to be informal
•
may not have enough information
•
Later Reviews
•
tend to be more formal
•
Feedback may come too late to avoid rework
Formality and Timing
•
Analysis is complete.
•
Design is complete.
•
After first compilation.
•
After first test run.
•
After first test run.
•
After all test runs.
•
Any time you complete an activity that produce a
complete work product.
Review Guidelines
•
Keep it short (< 30 minutes).
•
Don’t schedule two in a row.
•
Don’t review product fragments.
•
Use standards to avoid style disagreements.
•
Use standards to avoid style disagreements.
•
Let the coordinator run the meeting and
maintain order.
Scope Creep Effect
Scope Creep
Scope Creep
•
After the programming has started, users and
stakeholders make changes.
•
Each change is easy to describe, so it sounds
“small” and the programmers agree to it.“small” and the programmers agree to it.
•
Eventually, the project slows to a crawl
•
It’s 90% done –with 90% left to go
•
The programmers know that if they had been
told from the beginning what to build, they
could have built it quickly from the start.