ST Module1
ST Module1
BASIC DEFINITIONS
Error: Synonym of error is mistake. Mistakes made while coding are called as bugs. Errors
usually tend to propagate.
Ex: Requirement error may be magnified during design and amplified more during coding.
Failure: Failure occurs when a fault executes. Failures only occur in an executable
representation which is usually taken to be the source code.
Incident: An incident is the symptom associated with the failure that alerts the user to the
occurrence of a failure.
Test: Testing is concerned with errors, failures, faults and incidents. A test has two distinct
goals - to find failures or to demonstrate correct execution.
Test case: A test case has an identity and is associated with a program behaviour. It also has a
set of inputs and expected outputs.
Quality attributes: There exist several measures of software quality. These can be divided into
static and dynamic quality attributes.
Static quality attributes: Refers to actual code and related documentation. It includes structured,
maintainable, testable code as well as the availability of correct and complete documentation.
Dynamic quality attributes: Relate to the behaviour of the application while in use. It includes
software reliability, correctness, completeness, consistency, usability and performance.
Reliability:
The probability referred to in this definition depends on the distribution of the inputs to the
program. Such input distribution is often referred to as the operational profile. According to this
definition, software reliability could vary from one operational profile to another.
Implication is that one user might say “this program is lousy” while another might sing praises
for the same program.
Definition 2:
Software reliability is the probability of failure free operation of a software in its intended environment.
This definition is independent of “who uses what features of the software and how often”. Instead
it depends exclusively on the correctness of its features.
As there is no notion of operational profile, the entire input domain is considered as uniformly
distributed.
The term environment refers to the software and hardware elements needed to execute the
application. These elements include the OS, hardware requirements and any other applications
needed for communication.
Ex:
Two requirements are given below, each of which leads to a different program.
Requirement 1: It is required to write a program that inputs two integers and outputs maximum
of these.
Requirement 2: It is required to write a program that inputs a sequence of integers and outputs the
sorted version of this sequence.
Requirement 1 is incomplete:
Suppose that program Max is developed to satisfy a requirement 1 above. The expected output
of Max when the input integers are 13 and 19 can be easily determined to be 19.
Suppose now the tester wants to know if the two integers are to be input to the program in one
line followed by a carriage return or on two separate lines with a carriage return typed in after
each number. The requirement as stated above fails to provide an answer to this question.
Requirement 2 is ambiguous:
It is not clear from the requirement whether the input sequence is to be sorted in ascending or
descending order. The behaviour of sort program, written to satisfy this requirement, will depend
on the decision taken by the programmer while writing sort.
Regardless of the nature of the requirements, testing requires the determination of the expected
behaviour of the program under test. The observed behaviour of the program is compared with
the expected behaviour to determine if the program functions as desired.
For integer value, -32,768 to 32767 are the possible values. This requires 2 32 executions.
Testing a program on all possible inputs is known as “exhaustive searching”.
Ex:
Using requirement 1 above, we find the input domain of Max to be the set of all pairs of
integers where each element in the pair is in the range -32,768 till 32767.
Using requirement 2 it is not possible to find the input domain for the sort program.
Therefore, let us modify the requirement 2.
Modified requirement 2:
It is required to write a program that inputs a sequence of integers and outputs the integers in
the sorted manner in either ascending or descending order. The order of the output sequence is
determined by an input request character which should be “A” when an ascending sequence is
desired and “D” for descending.
While providing input to the program, the request character is entered first followed by the
sequence of integers to be sorted; the sequence is terminated with a period.
When using sort it is certainly possible for the user to type a character other than “A” or “D”.
Any character other than these is considered as invalid input to Sort. The requirement for sort
does not specify what actions it should take when an invalid input is encountered. Testing a
program against invalid inputs might reveal errors in the program.
Ex: Suppose we are testing the short program. We execute it against the following input : <E 7
19. > . Suppose that upon execution of the above input, the sort program interest to an infinite
loop and neither asks the user for any input nor response to anything typed by the user. This
observed behaviour points to a possible error in the sort.
Instead of typing an integer the user types in a character such as “?”, program should inform
the user that the input is invalid.
Input domain is partitioned into two subdomains: valid and invalid inputs.
Ex:
< D 7 9F 19. > Invalid
< A 7 19. > Valid
Correctness
A program is considered correct if it behaves as expected on each element of its input domain.
While correctness attempts to establish that the program is error free, testing attempts to find
if there are any errors in it. Thus, completeness of testing does not necessarily demonstrate that
a program is error free. Testing, debugging and the error removal processes together increase
our confidence in the correct functioning of the program under test.
Ex: This example illustrates why the probability of program failure might not change upon error
removal. Consider the following program that inputs two integers X and y and print the value
of f(x,y) or g(x,y) depending on the condition x<y .
The above program uses two functions f and g, not defined here. Let us assume that function f
produces incorrect result whenever it is invoked with x = y.
In its present form, the program fails when tested with equal input values because function g(x,
y) is invoked instead of function f. When the error is removed by changing the condition x<y to
x<=y, the program fails again when the input values are same. This is due to the error in function
f. In this program when the error in f is also removed, the program will be correct assuming that
all other code is correct.
Reliability:
Reliability of a program p is the probability of successful execution on a randomly selected
element from its input domain.
While correctness is a binary metric, reliability is a continuous metric over a scale from 0 to
1. A program can either be correct or incorrect. Its reliability can be anywhere between 0 and 1.
If it is known that p failed on exactly one of the three possible input pairs then the frequency
with which p will function correctly is 2/3. This number is an estimate of the probability of the
successful operation of p and hence it is the reliability of p.
Operational profile:
An operational profile is a numerical description of how a program is used. A program might
have several operational profiles depending on its users.
Ex: Consider a sort program which, on any given execution, allows any one of the two types of
input sequences. One sequence consists of numbers only and the other consists of
alphanumeric strings.
The different operational profiles for sort is specified as follows:
Steps are:
1. Preparing a test plan
2. Constructing test data
3. Executing the program
4. Specifying program behaviour
5. Assessing the correctness of program behaviour
6. Construction of Oracle.
Oracle can also be programs designed to check the behaviour of other programs.
Using programs as oracles has advantage of speed, accuracy and ease with which complex
computations can be checked.
6. 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.
TEST CASES
The essence of software testing is to determine a set of test cases for the item to be tested.
A complete test case will contain a test case identifier, a brief statement of purpose (e.g., a
business rule), a description of preconditions, the actual test case inputs, the expected outputs,
a description of expected post conditions, and an execution history.
The execution history is primarily for test management use—it may contain the date when the
test was run, the person who ran it, the version on which it was run, and the pass/fail result.
Test case execution entails establishing the necessary preconditions, providing the test case
inputs, observing the outputs, comparing these with the expected outputs, and then ensuring
that the expected post conditions exist to determine whether the test passed.
Test case ID
Purpose
Preconditions
Inputs
Expected outputs
Post conditions
Execution history
Date result version run by
A quick distinction is that the code-based view focuses on what it is and the behavioural view
considers what it does.
Consider a universe of program behaviours. Given a program and its specification, consider the
set S of specified behaviours and the set P of programmed behaviours.
Figure shows the relationship between the specified and programmed behaviours. Of all the
possible program behaviours, the specified ones are in the circle labelled S and all those
behaviours actually programmed are in P.
With this diagram, we can see more clearly the problems that
confront a tester. What if certain specified behaviours have not been
programmed? These are faults of omission. Similarly, what if certain
programmed (implemented) behaviours have not been specified?
These correspond to faults of commission and to errors that occurred
after the specification was complete. The intersection of S and P is
the “correct” portion, that is, behaviours that are both specified and
implemented.
Two fundamental approaches are used to identify test cases called functional testing
(specification based testing) and structural testing (code based testing).
The system is considered as a black box and hence the name black box
testing. In black box testing, the content (implementation) of the black
box is not known, and the function of the black box is understood
completely in terms of its inputs and outputs.
With the specification-based approach to test case identification, the only information used is
the specification of the software.
Advantages:
(1) They are independent of how the software is implemented, so if the implementation changes,
the test cases are still useful;
(2) Test case development can occur in parallel with the implementation, thereby reducing the
overall project development interval.
Disadvantages:
Significant redundancies may exist among test cases, compounded by the possibility of gaps of
untested software.
Figure shows the results of test cases identified by two specification-based methods. Method
A identifies a larger set of test cases than does method B. For both methods, the set of test cases
is completely contained within the set of specified behaviour.
Test coverage metrics provide a way to explicitly state the extent to which a software item has
been tested, and this in turn makes testing management more meaningful.
Figure shows the results of test cases identified by two code-based methods.
For both methods, the set of test cases is completely contained within the set of programmed
behaviour. Because code-based methods are based on the program, it is hard to imagine these
methods identifying behaviours that are not programmed.
Specification-based testing often suffers from twin problems of redundancies and gaps. When
specification-based test cases are executed in combination with code-based test coverage
metrics, both of these problems can be recognized and resolved.
Test generation strategies
One of the key tasks in any software test activity is the generation of test cases. The program
under test is executed against the test cases to determine whether it conforms to the
requirements.
Any form of test generation uses a source document. In the most informal of test methods, the
source document resides in the mind of the tester who generates tests based on knowledge of
Test cases
Fig: Requirements, Models and Test generation
The top row in the figure captures techniques that are applied directly to the requirements.
These May be informal techniques that assign values to input variables without the use of any
rigorous for formal methods.
These could also be techniques that identify input variables, captures the relationship among
these variables and use formal techniques for test generation and cause – effect graphing.
Another set of strategies falls under the category of model based test generation. These strategies
require that a subset of the requirements be modelled using a formal notation. Such a model is
also known as a specification of the subset of requirements.
FSMs, state charts, petri nets and times I/O automata are some of the well-known and used
formal notations for modelling various subsets of requirements.
Languages based on predicate logic as well as algebraic languages are also used to express
subsets of requirements in a formal manner. There also exists techniques to generate tests
directly from the code. Such techniques fall under code based test generation. These techniques
are useful when enhancing existing tests based on test adequacy criteria.
TEST METRICS:
Metrics refer to a standard of measurement.
Project metrics:
Project metrics relate to specific project. These are useful in monitoring and control of a specific
project. The ratio of actual to planned system test effort is one project metric.
Another project metric is the ratio of the number of successful tests to the total number of tests in the
system test phase.
Process metrics:
The goal of a process metric is to assess the goodness of the process.
When a Test process consists of several phases, for example unit test, integration test and
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 costlier it is to fix. Hence, a metric that classifies defects according
to the phase in which they are found assists in evaluating
Halstead metrics
The cyclomatic complexity proposed by Thomas Mc Cabe in 1976 is based on the control flow
of a program. Given the CFG G of program P containing N nodes, E edges and p connected
procedures, the cyclomatic complexity V (G) is computed as follows:
V (G) = E – N + 2p
The term p in V (G) counts only procedures that are reachable from the main function. V (G) is
the complexity of CFG G that corresponds to a procedure reachable from the main procedure.
Also, V(G) is not the complexity of the entire program, instead it is the complexity of a procedure
in p that corresponds to G. Larger values of V(G) tend to imply higher program complexity and
hence a program more difficult to understand and test than the one with a smaller values.
Halstead complexity measures using program size (S) and effort (E), the number of errors (B)
found during a software development effort:
Ex: The average number of testers working on a project is a static project metric. The number
of defects remaining to be fixed could be treated as a dynamic metric as it can be computed
accurately only after a code change has been made and the product retested.
Testability:
According to IEEE, testability is the “degree to which a system or component facilities the
establishment of test criteria and the performance of tests to determine whether those criteria have
been met”.
High testability is a desirable goal. This is best done by knowing well what needs to be tested
and how well in advance. Thus it is recommended that features to be tested and how they are
to be tested must be identified during the requirements stage. This information is then updated
during the design phase and carried over to the coding phase.
In more complex situations, it might require special hardware and probes in addition to special
features aimed solely at meeting a testability requirement.
SQA (Software Quality Assurance) tries to improve the product by improving the process.
SQA is more concerned with reducing errors in the development process, while testing is more
concerned with discovering faults in a product.
Faults can be classified in several ways: the development phase in which the corresponding
error occurred, the consequences of corresponding failures, difficulty to resolve, risk of know
resolution and so on.
The following table contains a fault taxonomy that distinguishes faults by the severity of their
consequences.
Verification might appear to be a perfect process as it promises to verify that a program is free
from errors. However, a close look at verification reveals that it has its own weakness. The
person who verified a program might have made mistakes in the verification process; there might
be an incorrect assumption on the input conditions; incorrect assumptions might be made
regarding the components that interface with the program; and so on. Thus, neither verification
nortestingis aperfecttechnique forprovingthecorrectness of programs.
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 execution of the application under test. Static testing
is useful in that lead to the discovery of faults in the application as well as ambiguities and
errors in the requirements and other application related documents that a relatively low cost.
This is especially so when dynamic testing is expensive.
Static testing is best carried out by an individual who did not write the code or by a team of
individuals. Simple process of static testing is illustrated
in the figure
Walkthrough begins with a review plan agreed upon by all members of the team. Each item of
the document for example resource module is reviewed with clearly stated objectives in view.
Detail report generated that list item of concern regarding the document reviewed.
Inspections
Inspection is a more formally define process than a walkthrough. This is usually associated with
code. Several organisations consider formal code instructions as a tool to improve code quality
at the lower cost.
Code inspection is carried out by a team. The team works according to an inspection plan that
consists of the following elements:
1. Statement of purpose
2. Work product to be inspected this includes code and associated documents needed for
inspection
3. Team formation, roles and tasks to be performed;
4. Rate at which the inspection task is to be completed.
5. 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 the inspection team are assigned roles of moderator, reader, recorder andauthor. The
moderator is in charge of the process and leads the review. Actual code is read by the reader,
perhaps with the help of code browser and with large monitors for all in the team to view the
code. The recorder records any errors discovered or issues to be looked into. The author is the
actual developer whose primary task is to help others understand the code.
Generalized Pseudocode
Pseudocode provides a language-neutral way to express program source code.
Problem Statement
Simple version: The triangle program accepts three integers, a, b, and c, as input. These are
taken to be sides of a triangle. The output of the program is the type of triangle determined by
the three sides: Equilateral, Isosceles, Scalene, or NotATriangle.
Improved version: The triangle program accepts three integers, a, b, and c, as input. These are
taken to be sides of a triangle. The integers a, b, and c must satisfy the following conditions:
C1. 1 ≤ a ≤ 200 c4. a < b + c
C2. 1 ≤ b ≤ 200 c5. b < a + c
c3. 1 ≤ c ≤ 200 c6. c < a + b
The output of the program is the type of triangle determined by the three sides: Equilateral,
Isosceles, Scalene, or NotATriangle. If an input value fails any of conditions c1, C2, or c3, the
program notes this with an output message, for example, “Value of b is not in the range of
permitted values.”
If values of a, b, and c satisfy conditions c4, c5, and c6, one of four mutually exclusive outputs
is given:
1. If all three sides are equal, the program output is Equilateral.
2. If exactly one pair of sides is equal, the program output is Isosceles.
3. If no pair of sides is equal, the program output is Scalene.
4. If any of conditions c4, c5, and c6 is not met, the program output is NotATriangle.
Problem Statement: NextDate is a function of three variables: month, date, and year. It returns the
date of the day after the input date. The month, date, and year variables have integer values
subject to these conditions (the year range ending in 2012 is arbitrary
C1. 1 ≤ month ≤ 12
C2. 1 ≤ day ≤ 31
c3. 1812 ≤ year ≤ 2012
We can make our problem statement more specific. This entails defining responses for invalid
values of the input values for the day, month, and year. We can also define responses for invalid
combinations of inputs, such as June 31 of any year. If any of conditions c1, C2, or c3 fails,
When a bank customer arrives at an SATM station, screen 1 is displayed. The bank customer
accesses the SATM system with a plastic card encoded with a personal account number (PAN),
which is a key to an internal customer account file, containing, among other things, the
customer’s name and account information. If the customer’s PAN matches the information in
the customer account file, the system presents screen 2 to the customer. If the customer’s PAN
is not found, screen 4 is displayed, and the card is kept.
At screen 2, the customer is prompted to enter his or her personal identification number (PIN).
If the PIN is correct (i.e., matches the information in the customer account file), the system
displays screen 5; otherwise, screen 3 is displayed. The customer has three chances to get the
PIN correct; after three failures, screen 4 is displayed, and the card is kept.
On entry to screen 5, the customer selects the desired transaction from the options shown on
screen. If balance is requested, screen 14 is then displayed. If a deposit is requested, the status
of the deposit envelope slot is determined from a field in the terminal control file. If no problem
is known, the system displays screen 7 to get the transaction amount. If a problem occurs with
the deposit envelope slot, the system displays screen 12.
Once the deposit amount has been entered, the system displays screen 13, accepts the deposit
envelope, and processes the deposit. The system then displays screen 14.
If a withdrawal is requested, the system checks the status (jammed or free) of the withdrawal
chute in the terminal control file. If jammed, screen 10 is displayed; otherwise, screen 7 is
displayed so the customer can enter the withdrawal amount.
Once the withdrawal amount is entered, the system checks the terminal status file to see if it
has enough currency to dispense. If it does not, screen 9 is displayed; otherwise, the withdrawal
is processed.
After the cash has been removed, the system displays screen 14. When the “No” button is
pressed in screens 10, 12, or 14, the system presents screen 15 and returns the customer’s
ATM card. Once the card is removed from the card slot, screen 1 is displayed.
When the “Yes” button is pressed in screens 10, 12, or 14, the system presents screen 5 so the
customer can select additional transactions.
QP QUESTIONS:
1. Why do we test software? Discuss what a typical test case information should include.
2. Differentiate between black box and white box testing
3. What is software testing? Why it is so important in software development life cycle?
4. Define the following a) error b)fault c)failure d)incident e)test f)testcases
5. Explain with a neat diagram the currency converter and Saturn wind shield wiper control
6. Write pseudo-code for commission problem
7. Explain basic definitions in perspective of testing
8. Define two fundamental approaches that are used to identify the test cases
9. Explain with diagram different steps involved in testing life cycle
10. Explain in detail fundamental approaches used to identify the test cases
11. State the triangle problem with all conditions also explain its traditional and its structural
implementations
12. Explain testing and debugging lifecycle with a neat diagram
13. List and explain different software quality attributes in detail
14. Explain structural and functional testing
15.Explain different types of software test metrics in detail
IMPORTANT QUESTIONS:
1. Define the following
a. Error b) fault c) failure d) incident e) test case f) exhaustive searching
g) Reliability h) correctness i) operational profile
2. Explain testing life cycle with a neat diagram
3. Explain types of software quality attributes
4. Explain testing and debugging life cycle with the help of a diagram
5. What is a test case? What should a typical test case information consist of?
6. Explain in detail two fundamental approaches that are used to identify test cases.
Or
Differentiate between specification based testing (functional testing) and code based
testing (structural testing)
7. With the help of a neat diagram, explain test generation strategies
8. Explain different types of test metrics
9. With the help of a neat diagram, explain levels of testing
Or