VTU B.E CSE Sem 8 Software Testing Notes
VTU B.E CSE Sem 8 Software Testing Notes
CHANNASANDRA, BANGALORE - 98
SOFTWARE TESTING
NOTES FOR 8TH SEMESTER INFORMATION SCIENCE
PREPARED BY
DIVYA K NAMRATHA R
1RN09IS016 1RN09IS028
8th Semester 8th Semester
Information Science Information Science
[email protected] [email protected]
SPECIAL THANKS TO
ANANG A – BNMIT & CHETAK M - EWIT
TEXT BOOKS:
FOUNDATIONS OF SOFTWARE TESTING – Aditya P Mathur, Pearson Education, 2008
SOFTWARE TESTING AND ANALYSIS: PROCESS, PRINCIPLES AND TECHNIQUES – Mauro Pezze, Michal Young, John
Wiley and Sons, 2008
Notes have been circulated on self risk. Nobody can be held responsible if anything is wrong or is improper information or insufficient information provided in it.
CONTENTS:
UNIT 1
BASICS OF SOFTWARE TESTING - 1
ERRORS AND TESTING
Humans make errors in their thoughts, in their actions, and in the products that might result from
their actions.
Humans can make errors in an field.
Ex: observation, in speech, in medical prescription, in surgery, in driving, in sports, in love and
similarly even in software development.
Example:
o An instructor administers a test to determine how well the students have understood what
the instructor wanted to convey
o A tennis coach administers a test to determine how well the understudy makes a serve
The programmer might misinterpret the requirements and consequently write incorrect code. Upon execution,
the program might display behaviour that does not match with the expected behaviour, implying thereby that a
failure has occurred.
A fault in the program is also commonly referred to as a bug or a defect. The terms error and a bug or a
defect. The terms error and bug are by far the most common ways of referring to something wrong in the
program text that might lead to a failure. Faults are sometimes referred to as defects.
Test Automation:
Testing of complex systems, embedded and otherwise, can be a human intensive task.
Execution of many tests can be tiring as well as error-prone. Hence, there is a tremendous need for
software testing.
Most software development organizations, automate test-related tasks such as regression testing,
graphical user interface testing, and i/o device driver testing.
The process of test automation cannot be generalized.
General purpose tools for test automation might not be applicable in all test environments
Ex:
Eggplant
Marathon
Pounder for GUI testing
Load & performance testing tools
eloadExpert
DBMonster
JMeter
Dieseltest
WAPT
LoadRunner
Grinder
SOFTWARE QUALITY
Software quality is a multidimensional quantity and is measurable.
Quality Attributes
These can be divided to static and dynamic quality attributes.
Example: A poorly documented piece of code will be harder to understand and hence difficult to modify.
A poorly structured code might be harder to modify and difficult to test.
Reliability:
It refers to the probability of failure free operation.
Correctness:
Refers to the correct operation and is always with reference to some artefact.
For a Tester, correctness is w.r.t to the requirements
For a user correctness is w.r.t the user manual
Completeness:
Refers to the availability of all the features listed in the requirements or in the user manual.
An incomplete software is one that does not fuly implement all features required.
Consistency:
Refers to adherence to a common set of conventions and assumptions.
Ex: All buttons in the user interface might follow a common-color coding convention.
Usability:
Refer to ease with which an application can be used. This is an area in itself and there exist
techniques for usability testing.
Psychology plays an important role in the design of techniques for usability testing.
Usability testing is a testing done by its potential users.
The development organization invites a selected set of potential users and asks them to test the
product.
Users in turn test for ease of use, functionality as expected, performance, safety and security.
Users thus serve as an important source of tests that developers or testers within the organization
might not have conceived.
Usability testing is sometimes referred to as user-centric testing.
Performance:
Refers to the time the application takes to perform a requested task. Performance is considered as a
non-functional requirement.
Reliability:
(Software reliability is the probability of failure free operation of software over a given time interval
& under given conditions.)
Software reliability can vary from one operational profile to another. An implication is that one
might say “this program is lousy” while another might sing praises for the same program.
Software reliability is the probability of failure free operation of software in its intended
environments.
The term environment refers to the software and hardware elements needed to execute the
application. These elements include the operating system(OS)hardware requirements and any
other applications needed for communication.
Definition: Correctness
State vector: collecting the current values of program variables into a vector known as the state vector.
An indication of where the control of execution is at any instant of time can be given by using an identifier
associated with the next program statement.
State sequence diagram can be used to specify the behavioural requirements. This same specification can then
be used during the testing to ensure if the application confirms to the requirements.
Construction of oracles:
Construction of automated oracles, such as the one to check a matrix multiplication program or a sort
program, Requires determination of I/O relationship. When tests are generated from models such as
finite-state machines(FSMs)or state charts, both inputs and the corresponding outputs are available.
This makes it possible to construct an oracle while generating the tests.
Example: Consider a program named Hvideo that allows one to keep track of home videos. In the data
entry mode, it displays a screen in which the user types in information about a DVD. In search mode, the
program displays a screen into which a user can type some attribute of the video being searched for and
set up a search criterion.
To test Hvideo we need to create an oracle that checks whether the program function correctly in data
entry and search nodes. The input generator generates a data entry request. The input generaor now
requests the oracle to test if Hvideo performed its task correctly on the input given for data entry.
The oracle uses the input to check if the information to be entered into the database has been entered
correctly or not. The oracle returns a pass or no pass to the input generator.
TEST METRICS
The term metric refers to a standard of measurement. In software testing, there exist a variety of metrics.
There are four general core areas that assist in the design of metrics schedule, quality, resources and size.
Size-related metrics:
Measure size of various objects such as the source code and number of tests in a test suite
Organizational metrics:
Metrics at the level of an organization are useful in overall project planning and management.
Ex: the number of defects reported after product release, averaged over a set of products developed and
marketed by an organization, is a useful metric of product quality at the organizational level.
Organizational metrics allow senior management to monitor the overall strength of the organization
and points to areas of weakness. Thus, these metrics help senior management in setting new goals and
plan for resources needed to realize these goals.
Project metrics:
Project metrics relate to a specific project, for example the I/O device testing project or a compiler
project. These are useful in the monitoring and control of a specific project.
1. Actual/planned system test effort is one project metrics. Test effort could be measured in terms
of the tester_man_months.
𝑛𝑜 .𝑜𝑓 𝑠𝑢𝑐𝑐𝑒𝑠𝑠 𝑓𝑢𝑙 𝑡𝑒𝑠𝑡𝑠
2. Project metric=𝑡𝑜𝑡𝑎𝑙 𝑛𝑢𝑚𝑏𝑒𝑟 𝑜𝑓 𝑡𝑒𝑠𝑡𝑠 𝑖𝑛 𝑡ℎ𝑒 𝑠𝑦𝑠𝑡𝑒𝑚 𝑝ℎ𝑎𝑠𝑒
Process metrics:
Every project uses some test process. Big-bang approach well suited for small single person projects.
The goal of a process metric is to assess the goodness of the process.
Test process consists of several phases like unit test, integration test, system test, one can measure how
many defects were found in each phase. It is well known that the later a defect is found, the consttier it
is to fix.
Cyclomatic complexity
V(G)= E-N+2P
Program p containing N node, E edges and p connected procedures.
Larger value of V(G)higher program complexity & program more difficult to understand &test than one
with a smaller values.
V(G) values 5 or less are recommended
Halstead complexity
Number of error(B) found using program size(S) and effort(E)
B= 7.6𝐸 0.667 𝑆 0.33
Testability:
According to IEEE, testability is the “degree to which a system or component facilitates the
establishment of test criteria and the performance of tests to determine whether those criteria have
been met”.
Two types:
static testability metrics
dynamic testability metrics
Dynamic metrics for testability includes various code based coverage criteria.
Ex: when it is difficult to generate tests that satisfy the statement coverage criterion is considered to have low
testability them one for which it is easier to construct such tests.
UNIT 2
BASICS OF SOFTWARE TESTING - 2
SOFTWARE AND HARDWARE TESTING
There are several similarities and differences between techniques used for testing software and hardware
Software application Hardware product
Does not integrate over time Does integrate over time
Fault present in the application will remain and no VLSI chip, that might fail over time due to a fault that
new faults will creep in unless the application is did not exist at the time chip was manufactured and
changed tested
Built-in self test meant for hardware product, rarely, BIST intended to actually test for the correct
can be applied to software designs and code functioning of a circuit
It only detects faults that were present when the last Hardware testers generate test based on fault-models
change was made Ex: stuck_at fault model – one can use a set of input
test patterns to test whether a logic gate is functioning
as expected
Software testers generate tests to test for correct functionality.
Sometimes such tests do not correspond to any general fault model
For example: to test whether there is a memory leak in an application, one performs a combination of
stress testing and code inspection
A variety of faults could lead to memory leaks
Hardware testers use a variety of fault models at different levels of abstraction
Example:
o transistor level faults low level
o gate level, circuit level, function level faults higher level
Software testers might not or might use fault models during test generation even though the model
exist
Mutation testing is a technique based on software fault models
Test Domain a major difference between tests for hardware and software is in the domain of tests
Tests for VLSI chips for example, take the form of a bit pattern. For combinational circuits, for example a
Multiplexer, a finite set of bit patterns will ensure the detection of any fault with respects to a circuit
level fault model.
For software, the domain of a test input is different than that for hardware. Even for the simplest of
programs, the domain could be an infinite set of tuples with each tuple consisting of one or more basic
data types such as integers and reals.
Example
DEFECT MANAGEMENT
Defect Management is an integral part of a development and test process in many software development
organizations. It is a sub process of a the development process. It entails the following:
Detect prevention
Discovery
Recording and reporting
Classification
Resolution
Production
Defect Prevention
It is achieved through a variety of process and tools: They are,
Good coding techniques.
Unit test plans.
Code Inspections.
Defect Discovery
Defect discovery is the identification of defects in response to failures observed during dynamic testing
or found during static testing.
It involves debugging the code under test.
Defect Classification
Defects found are classified and recorded in a database. Classification becomes important in dealing with the
defects. Classified into
High severity-to be attended first by developer.
Low severity.
Example: Orthogonal defect classification is one of the defect classification scheme which exist called ODC, that
measures types of defects, this frequency, and Their location to the development phase and documents.
Resolution
Each defect, when recorded, is marked as ‘open’ indicating that it needs to be resolved. It required careful
scrutiny of the defects, identifying a fix if needed, implementing the fix, testing the fix, and finally closing the
defect indicating that every recorded defect is resolved prior to release.
Defect Prediction
Organizations often do source code Analysis to predict how many defects an application might contain
before it enters the testing the phase.
Advanced statistical techniques are used to predict defects during the test process.
Tools are existing for Recording defects, and computing and reporting defect related statistics.
o BugZilla - Open source
o Fog-Buzz - commercially available tools.
EXECUTION HISTORY
Execution history of a program, also known as execution trace, is an organized collection of information about
various elements of a program during a given execution. An execution slice is an executable subsequence of
execution history. There are several ways to represent an execution history,
Sequence in which the functions in a given program are executed against a given test input,
Sequence in which program blocks are executed.
Sequence of objects and the corresponding methods accessed for object oriented languages such as Java
An execution history may also included values of program variables.
A complete execution history recorded from the start of a program’s execution until its termination
represents a single execution path through the program.
It is possible to get partial execution history also for some program elements or blocks or values of
variables are recorded along a portion of the complete path.
STATIC TESTING
Static testing is carried out without executing the application under test.
This is in contrast to dynamic testing that requires one or more executions of the application under test.
It is useful in that it may lead to the discovery of faults in the application, ambiguities and errors in the
requirements and other application-related document, at a relatively low cost,
This is especially so when dynamic testing expensive.
Static testing is complementary to dynamic testing.
This is carried out by an individual who did not write the code or by a team of individuals.
The test team responsible for static testing has access to requirenments document, application, and all
associated documents such as design document and user manual.
Team also has access to one or more static testing tools.
A static testing tool takes the application code as input and generates a variety of data useful in the test
process.
WALKTHROUGHS
Walkthroughs and inspections are an integral part of static testing.
Walkthrough are an integral part of static testing.
Walkthrough is an informal process to review any application-related document.
eg:
requirements are reviewed---->requirements walkthrough
code is reviewed---->code walkthrough
(or)
peer code review
Walkthrough begins with a review plan agreed upon by all members of the team.
Advantages:
improves understanding of the application.
Prepared By: DIVYA K [1RN09IS016] & NAMRATHA R [1RN09IS028] Page 16
RNSIT SOFTWARE TESTING NOTES
INSPECTIONS
Inspection is a more formally defined process than a walkthrough. This term is usually associated with
code.
Several organizations consider formal code inspections as a tool to improve code quality at a lower cost
than incurred when dynamic testing is used.
Inspection plan:
i. statement of purpose
ii. work product to be inspected this includes code and associated documents needed for inspection.
iii. team formation, roles, and tasks to be performed.
iv. rate at which the inspection task is to be completed
v. Data collection forms where the team will record its findings such as defects discovered, coding
standard violations and time spent in each task.
(a) CFG clearly shows that the definition of x at block 1 is used at block-3 but not at block 5.In fact the definition
of x at block 1 is considered killed due to its redefinition at block 4.
(b) CFG indicates the use of variable y in the block 3.If y is not defined along the path from start to block 3,then
there is a data-flow error as a variable is used before it is defined.
Several such errors can be detected by static analysis tools.
->compute complexity metrics, used as a parameter in deciding which modules to inspect first.
o Above diagram illustrates the process of model-checking. A model, usually finite state is extracted from
some source. The source could be the requirements and in some cases, the application code itself.
o One or more desired properties are then coded to a formal specification language. Often, such
properties are coded in temporal logic, a language for formally specifying timing properties. The model
and the desired properties are then input to a model checker. The model checker attempts to verify
whether the given properties are satisfied by the given model.
o For each property, the checker could come up with one of three possible answer:
o the property is satisfy
o the property is not satisfied.
o or unable to determine
o In the second case, the model checker provides a counter example showing why the property is not
satisfied.
o The third case might arise when the model checker is unable to terminate after an upper limit on the
number of iterations has reached.
o While model checking and model based testing use models, model checking uses finite state models
augmented with local properties that must hold at individual states. The local properties are known as
atomic propositions and augmented models as kripke structure.
Basic Block
Let P denotes a program written in a procedural programming language, be it high level as C or Java or
low level such as the 80x86 assembly. A basic block, or simply a block, in P is a sequence of consecutive
statements with a single entry and a single exit point.
Thus, a block has unique entry and exit points.
Control always enters a basic block at its entry point and exits from its exit point. There is no possibility
of exit or a halt at any point inside the basic block except at its exit point. The entry and exit points of a
basic block co inside when the block contains only one statement.
example: the following program takes two integers x and y and output x^y.
TYPES OF TESTING
Framework consists of a set of five classifies that serve to classify testing techniques that fall under the
dynamic testing category.Dynamic testing requires the excution of program under test.Static testing
consists of testing for the review and analysis of the program.
five classifiers of testing:-
o 1.C1:source of test generation
o 2.C2:life cycle phase in which testing takes place
o 3.C3:goal of a specific testing activity.
o 4.C4:characteristics of the artifact under test
o 5.C5:test process
Interface testing:
Tests are often generated using a components interface.
Interface itself forms a part of the components requirements and hence this form of testing is black box
testing. However, the focus on the interface leads us to consider interface testing in its own right.
Techniques such as
o --->pairwise testing
o --->interface mutation
Pairwise testing:
Set of values for each input is obtained from the components requirement.
Interface mutation:
The interface itself, such as function coded in /c orCORBA component written in an IDL,serves to
extract the information needed to perform interface mutation.
o pairwise testing:is a black box testing
o interface mutation:is a white box testing
Ad-hoc testing:
In adhoc testing,a tester generates tests from requirements but without the use of any systematic
method.
Random testing:
Random testing uses a systematic method to generate tests.Generation of tests using random testing
requires modeling the input space randomly.
Spiral testing:
The term spiral testing is not to be confused with spiral model, through they both are similar in that
both can be visually represented as a spiral of activities.
In the spiral testing, the sophisticated of testing of test activities increases with the stages of an evolving
prototype.
In the early stages, when a prototype is used to evaluate how an application must evolve, one focuses on
test planning. The focus at this stage is on how testing will be performed in the remainder of the project.
Subsequent iterations refine the prototype based on more precise set of requirements.
Further test planning takes place and unit & integration tests are performed.
In the final stage ,when the requirements are well defined, testers focus on system and acceptance
testing.
Agile testing:
Agile testing involves in addition to the usual steps such as test planning, test design and test execution.
Agile testing promotes the following ideas:
Include testing -related activities throughout a development project starting from the requirement phase.
Work collaboratively with the customer who specifies requirements in terms of tests.
testers and development must collaborate with each other rather than serve as adversaries and
Test often and in small chunks.
Reliability in the figure refers to the probability of failure free operation of the application under test in
its intended environment.
The true reliability differs from the estimated reliability in that the latter is an estimate of the
application reliability obtained by using one of the many statistical methods.
o 0-indicates lowest possible confidence
o 1-the highest possible confidence
Similarly,
o 0-indicates the lowest possible true reliability
o 1-the highest possible true reliability.
Saturation region:
->assumes application A in the system test phase.
->the test team needs to generate tests, set up the test environment, and run A against the test.
1. Assume that the testers are generated using a suitable test generation method (TGAT 1) and that
each test either passes or fails.
2. If we measure the test effort as the combined effort of testing, debugging and fixing the errors the
true reliability increases as shown in the fig.
False sense of confidentiality:
This false sense of confidence is due to the lack of discovery of new faults, which in turn is due to the
inability of the tests generated using TGA1 to exercise the application code in ways significantly
different from what has already been exercised.
Thus, in the saturation region, the robust states of the application are being exercised, perhaps
repeatedly, whereas the faults lie in the other states.
Reducing delta:
Empirical studies reveal that every single test generation method has its limitations in that the resulting
test set is unlikely to detect all faults in an application.
The more complex an application, the more unlikely it is that tests generated using any given method
will detect all faults.
This is one of the prime regions why tests use or must use multiple techniques for test generation.
Prepared By: DIVYA K [1RN09IS016] & NAMRATHA R [1RN09IS028] Page 25
RNSIT SOFTWARE TESTING NOTES
Impact on test process:
A knowledge and application of the saturation effect are likely to be of value of any test team while
designing and implementing a test process.