ST Mod 1
ST Mod 1
Module I
Module - I
Chapter 1 Basics of Software Testing
Basic Definitions
Error: people make errors. A good synonym is mistake. When people make mistakes
while coding, we call these mistakes as bugs. Errors tend to propagate and requirements
error may be magnified during design and amplified still more during coding.
Fault: a fault is the result of an error. It is more precise to say that a fault is the
representation of an error, where representation is the mode of expression, such as
narrative text, data flow diagrams, hierarchy charts, source code, and so on. Defect is a
good synonym for fault.
Types of Fault:
- Fault of omission occurs when we fail to enter correct information. (Some details are
missed out in specifications and additional details are implemented)
- Fault of commission occurs when we enter something into a representation that is
incorrect. (Mentioned in Specifications but missed out while implementing) or
Omission/commission:
Omission - neglecting to include some entity in a module
Commission - incorrect executable statement
Failure: a failure occurs when a fault executes. Two subtleties arise here: one is that
failures only occur in an executable representation, which is usually taken to be source
code, or loaded object code and the second subtlety is that, this definition relates failures
only to faults of commission.
Incident: when a failure occurs, it may or may not be readily apparent to the user (or
customer or tester). An incident is the symptom associated with a failure that alerts the user
to the occurrence of failure.
Test: testing is concerned with errors, faults, failures, and incidents. A test is the act of
exercising software with test cases. A test has two distinct goals: to find failures or to
demonstrate correct execution.
Test Case: test case has an identity and is associated with a program behavior. A test case
also has a set of inputs and a list of expected outputs.
What is testing?
Software testing is a process used to identify the correctness, completeness and
quality of developed computer software. or
The process of devising a set of inputs to a given piece of software that will cause the
software to exercise some portion of its code.
The developer of the software can then check that the results produced by the software are
in accord with his or her expectations.
Note: Rigorous reviews are more effective, and more cost effective, than any other error-
removal strategy, including testing. But they cannot and should not replace testing.
VV
The below figure depicts life cycle model for testing. Three stages in which errors may be
introduced resulting in faults that propagate through the remainder of the development
process.
Figure: A Testing Life Cycle
Test cases occupy the central place in Testing. Testing can be subdivided into: test
planning, test case development, running test cases and evaluating test results.
Test cases
• Aim of testing is to determine a set of test cases. The below information should be in a test
case.
Inputs: Pre-conditions (circumstances that hold prior to test case execution), Actual Inputs
identified by some testing method.
Expected Outputs: Post- conditions and actual outputs
• Consider a universe U of program behaviors in the above Venn diagram. Here, program
and its specifications are given. We can see from the above diagram that Set S contains
specified behaviors among all possible program behaviors and set P contains all those
behaviors actually programmed. The intersection of S and P is the portion where
behaviors that are both specified and implemented. This is the very good view of testing
that determines the extent of program behavior.
• In the figure below, consider the relationships among S, P, and T (Test cases). We can
find, there may be specified behaviors that are not tested correspond to the regions 2 and 5,
specified behaviors that are tested correspond to the regions 1 and 4, and test cases that
correspond to unspecified behaviors in regions 3 and 7.
Figure: Specified, implemented and tested behaviors
U
VV
• Similarly, there may be programmed behaviors that are not tested correspond to the regions
2 and 6, programmed behaviors that are tested correspond to the regions 1 and 3, and test
cases that correspond to unprogrammed behaviors in regions 4 and 7.
• All regions are important. If specified behaviors exist for which no test cases are available,
the testing is incomplete. If some test cases correspond to unspecified behaviors, then some
possibilities arise: test case is unwarranted or specification is deficient or tester wishes to
determine that specified nonbehavior does not occur.
Functional Testing
• Functional Testing is based on the view that any program can be considered to be a
function that maps values from input domain to values in the output range. This
notion is used when systems are considered to be black boxes. In black box testing, the
content or implementation of a black box is not known and its function is understood
completely in terms of its inputs and outputs.
• Example: Most people successfully operate automobiles with only black box
knowledge. Here, only specifications of software are used to identify test cases.
Figure: An Engineer‟s black box.
Inputs Outputs
• Figure below shows result of test cases identified by two functional methods. Method
A identifies larger set of test cases than Method B. For both the methods, the set of test
cases is completely contained within the set of specified behavior. It is hard to identify
behaviors that are not specified.
• Black Box - A strategy in which testing is based on requirements and specifications
VV
Structural Testing
• Structural Testing is another approach to test case identification. It is also called as
White Box, Clear Box, Glass box and Open box testing. Function is understood only
in terms of its implementation and used to identify test cases.
Inputs Outputs
VV
• With the knowledge of graph theory, the tester can rigorously describe exactly what is
testing. Structural testing provides the definition by itself and it uses the test coverage
metrics. The test coverage metrics provide a way to explicitly state the extent to which
software has been tested and this makes testing management more meaningful. The
figure above depicts the path flow testing.
• Figure below shows the result of test cases identified by two Structural methods.
Method A identifies larger set of test cases than Method B. In both methods, the set of
test cases is completely contained within the set of programmed behavior.
• White Box: A strategy in which testing is based on internal parts, structure, and
implementation.
Figure: Comparing structural test case identification
Input/output Faults
Type Instances
Input Correct input not accepted
Incorrect input accepted
Description wrong or missing
Parameters wrong or missing
Output Wrong format
Wrong result
Correct result at wrong time(too early, too late)
Incomplete or missing result
Spurious result
Spelling/grammar
Cosmetic
Logic Faults
Missing Case(s)
Duplicate Case(s)
Extreme condition neglected
Misinterpretation
Missing condition
Extraneous condition(s)
Test of wrong variable
Incorrect loop iteration
Wrong operator (e.g.,< instead of <=)
Computation Faults
Incorrect algorithm
Missing computation
Incorrect operand
Incorrect operation
Parenthesis error
Insufficient precision (round-off, truncation)
Interface faults
Incorrect interrupt handling
I/O timing
Call to wrong procedure
Call to nonexistent procedure
Parameter mismatch(type, number)
Incompatible types
Superfluous inclusion
Data Faults
Incorrect initialization
Incorrect storage/access
Wrong flag/index value
Incorrect packing/unpacking
Wrong variable used
Wrong data reference
Scaling or units error
Incorrect data dimension
Incorrect subscript
Incorrect type
Incorrect data scope
Sensor data out of limits
Off by one
Inconsistent data
Levels of Testing
• Figure below shows the Levels of abstraction and testing in the waterfall model. Levels of
testing echo the levels of abstractions found in the waterfall model of the Software
Development Life Cycle (SDLC).
• It helps to identify distinct levels of testing and for clarification of objectives of each
level. In terms of functional testing, the three levels of definition correspond directly to
three levels of testing – system, integration, and unit testing.
• A practical relationship exists between levels of testing versus functional and structural
testing.
• Structural testing is more appropriate at unit level and functional testing is at more
appropriate at system level.
VV
Software quality
Software quality is a multidimensional quantity and is measurable.
Quality attributes
There exist several measures of software quality. These can be divided into static and
dynamic quality attributes.
• Static quality attributes include structured, maintainable and testable code as well
as the availability of correct and complete documentation.
• Dynamic quality attributes include software reliability, correctness, completeness,
consistency, usability and performance.
- Reliability refers to the probability of failure free operation.
- Correctness refers to the correct operation of an application and is always with
reference to some artifact.
- Completeness refers to the availability of all features listed in the requirements, or
in the user manual. Incomplete software is one that does not fully implement all
features required.
- Consistency refers to adherence to a common set of conventions and
assumptions. For example, all buttons in the user interface might follow a common
color coding convention.
- Usability refers to the ease with which an application can be used.
- Performance refers to the time the application takes to perform a requested
task.
Reliability
Software reliability is the probability of failure free operation of software over a given
time interval and under given conditions.
VV
The requirement for sort does not specify what action it should take when an invalid
input is encountered. Example: < E 7 19 . > Now the sort program enters into infinite
loop.
• Further the modified input domain consists of pair of values in which the first value is
the request character and the second is the sequence of integers combined with
invalid characters terminated by a period. Example: < D 7 9F 19 . >. From this it is
assumed that invalid characters are possible inputs to sort program.
• In the next step, it is advisable to separate valid and invalid inputs and can be used for
testing.
Reliability
• The reliability of a program P is the probability of its successful execution on a
randomly selected element from its input domain. Example: Consider a program P
whose inputs are {< (0, 0) (-1, 1) (1, -1)>}. If it is known that P fails on exactly one of
the three possible input pairs then the frequency with which P will function correctly is
2
3.
Program Use and the Operational profile
• An operational profile is a numerical description of how a program is executed and
used.
• Example: Consider a sort program, on any given execution allows any one of two
types of input sequences. Sample operational profiles for sort are as follows.
Operational Profile #1
Sequence Probability
Numbers Only 0.9
Alphanumeric strings 0.1
VV
Operational Profile #2
Sequence Probability
Numbers Only 0.1
Alphanumeric strings 0.9
1. Execute sort on at least two input sequences, one with “A” and the other with
“D” as request characters.
2. Execute the program on an empty input sequence.
3. Test the program for robustness against erroneous inputs such as “R” typed in as
the request character.
4. All failures of the test program should be recorded in a suitable file using the
Company Failure Report Form.
1. integer X, Y, Z;
2. input (X, Y);
3. if (X<Y)
4. {Z=Y;}
5. else
6. {Z=X;}
7. endif
8. output(Z);
9. end
VV
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 HVideo to keep track of home videos, which operates
in two modes. In the data entry mode it displays a screen in which the user types in
information about a DVD such as title, comments and created date etc., and stored in
database. In search mode the program displays a screen into which a user can type
some attribute of the DVD to be searched.
• To test HVideo program we need to create an oracle that checks whether the HVideo
program functions correctly in data entry and search modes. In below figure, the
input generator generates a data entry request. After completion of request, HVideo
returns control to the input generator. The input generator now requests the oracle to
test if, HVideo (program) performed its task correctly on the input given.
• 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. Similarly it is carried for search mode also.
VV
• The top row captures techniques that are applied directly to the requirements. Another set
of strategies falls under the category of model-based test generation. These strategies
require that a subset of the requirements be modeled using a formal notation.
VV
• Languages based on predicate logic as well as algebraic languages are also used to
express subsets of requirements. This model is also known as specification of the subset
of requirements.
• Finite State Machines, state charts, timed I/O automata and Petri nets are some of the
formal notations for modeling various subsets of the requirements. Code based test
generation generate tests directly from the code.
Test Metrics
• The term metric refers to a standard of measurement. In software testing there exist a
variety of metrics.
Figure: Types of metrics used in software testing and their relationships
• There are four general core areas that assist in the design of metrics. They are schedule,
quality, resources and size.
- Schedule related metrics: Measure actual completion times of various activities and
compare these with estimated time to completion.
- Quality related metrics: Measure quality of a product or a process.
- Resource related metrics: Measure items such as cost, man power and test
execution.
- 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. Example: the number of defects reported after product release, average
of products developed and marketed by an organization is a useful metric of product
quality.
• 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.
VV
Project metrics
• Project metrics relate to a specific project. The I/O device testing project or compiler
design projects are the examples. These are useful in the monitoring and control of a
specific project.
• The ratio of Actual-to-planned system test effort is one project metric. Test effort
could be measured in terms of the tester-man-months.
• Another project metric is the ratio of number of successful tests to the total number
of tests in the system test phase.
Process metrics
• Every project uses some test process. The big-bang approach is well suited for small
single person projects. The goal of a process metric is to assess the goodness of the
process.
• When test process consists of several phases like unit test, integration test and system
test, one can measure how many defects were found in each phase. The defects should
not be carried from one phase of testing to other phase. Otherwise the cost of testing
will become high.
Program vocabulary n n1 + n2
Program size N N1 + N2
Program Volume V N ∗ log2 N
Difficulty D 2/n1 ∗ n2/N2
Effort E D∗V
Metric Meaning
Reliability Probability of failure of a software product with respect to a
given operational profile in a given environment
Defect density Number of defects per KLOC (thousands lines of code)
Defect severity Distribution of defects by their level of severity
Test coverage Fraction of testable items, e.g. basic blocks, covered. Also a
metric for test adequacy or goodness of tests
Cyclomatic Measures complexity of a program based on its CFG
complexity
Weighted methods ∑𝑛 𝑐𝑖 ci is the complexity of method i in the class under
𝑖=1
per class consideration
Class coupling Measures the number of classes to which a given class is
coupled
Response set Set of all methods that can be invoked, directly and indirectly,
when a message is sent to object O
Number of children Number of immediate descendants of a class in the class
hierarchy
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 ways to measure testability of a product are static testability metrics and
dynamic testability metrics. Software complexity is one of the static testability metric.
The more complex an application the lower the testability, i.e., higher effort is
required to test it.
• Dynamic metrics for testability includes various code based coverage criteria.
Example: when it is difficult to generate tests that satisfy the statement coverage
criterion then it is considered to have low testability.
Static Testing
• Static testing is carried out without executing the application under test. It is useful in
discovery of faults in the application, ambiguities and errors in the requirements at a
relatively low cost.
• This is carried out by an individual who did not write the code or by a team of
individuals. A sample process of static testing is illustrated in below figure. The test team
responsible for static testing has access to requirements 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.
VV
Walkthroughs
• Walkthroughs and inspections are an integral part of static testing. Walkthrough is an
informal process to review any application-related document.
• Example: Requirements are reviewed using requirements walkthrough, code is
reviewed using code walkthrough (or) peer code review. Walkthrough begins with a
review plan agreed upon by all members of the team.
• Review improves understanding of the application. Both functional and non functional
requirements are reviewed. A detailed report is generated that lists items of concern
regarding the requirements.
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.
• Code inspection is carried out by a team. The team works according to Inspection plan
that consists of the following elements,
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.
• Members of inspection team are assigned roles of
- Moderator: in charge of the process and leads the review.
- Leader: actual code is read by the reader, perhaps with help of a code browser and
with monitors for all in the team to view the code.
- Recorder: records any errors discovered or issues to be looked into.
- Author: actual developer of the code.
to the inspection team which allows the determination of the flow of control under
different conditions. A CFG can be annotated with data flow information to make a data
flow graph. This information is valuable to the inspection team in understanding the
code as well as pointing out possible defects.
• Two commercially available static code analysis tools are Purify from IBM Rationale
and Klockwork from Klockwork. LAPSE (Light weight Analysis for Program Security
in Eclipse) is an open source tool for analysis of Java programs.
Module I
1. Define the terms
Error, Fault, Failure, Incident, Test, Test cases
2. Write diagram and explain life cycle Model of testing.
3. Explain test cases based on typical test case information.
4. Explain Specified and Implemented program behaviors with Venn diagram. Extend the
same with test cases.
5. Explain how Functional testing is done with diagram of functional test case identification
methods.
6. Explain how structural testing is done with diagram of functional test case identification
methods.
7. Differentiate Functional testing with Structural testing.
8. How error and faults can be classified? List them and give some example for each.
9. Write and explain Levels of testing with waterfall model..
10. What is software quality?
11. What is meant by static and dynamic quality attributes?
12. Explain different dynamic quality attributes in detail.
13. Define reliability.
14. Briefly discuss about incompleteness and ambiguity of the requirements with example.
15. Write a note on valid and invalid inputs.
16. Define input domain and correctness of the program.
17. Discuss about testing and debugging with a neat diagram.
18. Give a test plan to test a sort program.
19. Briefly explain the different types of test metrics.
20. Explain in detail about test harness.
21. With an example explain about behavior of a program.
22. What is an oracle? Discuss about the relationship between the program under test and
oracle.
23. Write a note on various types of test metrics.
24. Explain in detail about testing and verification.
25. With a neat diagram explain test generation strategies.
26. Explain in detail about Static testing.
VV