Professional Documents
Culture Documents
Tech—Akash Books 45
SOFTWARE TESTING
Q. 1. (a) What is Branch Testing?
Ans. It is a measure of how many branches or decisions in a module have been
executed during testing. If the Branch coverage is (95% for new code or 75% for code
under maintainenence then the test scripts require review and enhancement.
(b) Difference between Validation and Verification testing.
Ans.
Verification Validation
1. It is a static process of verifying 1. It is a dynamic process of validating/
documents, design and code. testing the actual product.
2. It does not involve executing the
2. It involves executing the code.
code.
3. I t is hu m a n ba se d c h eck i n g of 3. It is computer based execution of
document files. program.
4. It uses methods like inspections, 4. It uses methods like black-box, gray
walke throughs, Desk-checking etc. box, white box testing etc.
5. It generally, comes first–done before 5. It generally follows verification.
validation.
6. It can catch errors that verification
6. It can catch errors that validation
cannot catch.
cannot catch.
Testing
a<x<b
c<y<d
d
c
a b
Thus, for a program of n variables, boundary value analysis yields 4n + 1 test cases.
(ii) Equivalence Class Testing: In this method, input domain of a program is
partitioned into a finite number of equivalence classes and one can assume that the
test of a representative value of each class is equivalent to that of any other value i.e., if
one test case in a class detects an error, than all other test cases would be expected to
find the same error. The idea of equivalence class testing is to identify the test cases by
using one element from each equivalence class.
(iii) Decision Table Based Testing: Decision tables are precise and compact way
of modelling complicated.
This technique is ideal for situations where number of combinations of actions are
taken under varying set of conditions.
It consists following 4 potions:
(a) Stub portion
(b) Entry potion
(c) Condition portion, and
(d) Action portion.
Rules
Q.3. (a) What is White box testing? Explain with its types. Write its advantages
and disadvantages
Ans. White BOX testing is a way of testing the external functionality of the code by
examining and testing the program code. White BOX testing is used to test the program
code, code structure and internal design flow.
White Box testing is of two types:
1. Static White BOX testing.
2. Dynamic white BOX testing.
Static Testing: Static testing is a type of testing in which the program source code
is tested without running it we only need to examine and review the code we need not to
execute the code. We need to find out whether.
• The code works according to the functional requirements.
• The code has been written in accordance with the design developed earlier in
the project life cycle.
• The code handlles errors properly.
Static testing can be done by humans or with the help of specialized tools.
Dynamic White Box Testing: In dynamic testing, we test a running program. In
this we try to test the internal logic of the program. It involves running the actual product
against some pre-designed test cases to exercise as much of the code as possible.
Whole box Testing
Statement
coverage
Path
coverage
Condition
coverage
Function
coverage
Advantage of White Box Testing:
1. White Box testing helps us to identify memory leaks. When we allocate
memory, we should explicity release that memory also. If this is not done
then over time, there would be no memory available for allocating memory
on requests. This can be done using debuggers also that can tally allocated
and freed memory.
2. Performance Analysis: Code coverage tests can identify the areas of code
that are executed most frequently.
3. White Box testing is useful in identifying boltleneeks in resource usage.
4. White Box testing can help identify security holes in dynamically generated
code.
5. Testing can be commenced at an earlier stage, one need not wait for the GUI
to be available.
Disadvantages of White Box Testing
1. Since tests can be very complex, highly skilled resources are required, with
thorough knowledge of programming and implementation.
2. Test script maintainance can be burden if the implementation changes too
frequently.
3. Since this method of testing is closely tied with the application being testing,
tools to cater to every kind of implementation/platform maynot be readily
available.
(b) Describe three ways to find out the Cyclomatic Complexity of a program
or flow chart?
Ans. The cyclomatic complexity is also known as structural complexing because it
gives internal view of the code. This approach is used to find the number of independent
paths through a program. This provides us the upper bound for the number of tests that
must be conducted to ensure that all statements have been executed at least once and
every condition has been executed on its true and false side.
Cyclomatic complexity can be calculated by one of the three methods.
First Method: Cyclomatic complexing V(G) of a graph G with n vertices, e edges
and p connected components is calculated as
V (G) = e − n + 2 p
C F
D
E
G
H N
I J O P
K L
M
Q
R
DD Path graph
Second Method: Cyclomatic complexity V(G) of a flow graph G is equal to the
number of predicate (decision) nodes plus one.
V (G) = π + 1
where π is the number of predicate nodes contained in the flow graph G.
Third Method: Cyclomatic complexing is equal to the number of regions of the flow
graph.
V (G) = number of regions
for example, consider the DD path graph of the triangle Problem.
Cyclomatic complexity by the first method can be calculated as
V (G) = e − n + 2 p
Number of edges, e = 23
Number of nodes, n = 18
V(G) = 23 – 18 + 2 = 7
ByII nd Method: Cylomatic complexing will be calculated as
V(G) = π + 1
= 6+1=7
By 33rd Method Cyclomatic complexity will be calculated as
V(G) = Number of regions = 7
The cyclomatic complexing is 7. Hence, there are seven independent paths.
Q.4. (a) How can we reduce number of test cases in Black Box Testing?
Explain with example.
Ans. Equivalence partitioning method is used to reduce the total number of test
cases in black box testing. In this method the input domain data is divided into different
equivalence data classes. This method is typically used to reduce the total number of
test cases into a finite set of testable test cases, still covering maximum requirements.
In short it is the process of taking all possible test cases and placing them into classes.
One test value is picked from each class while testing.
For example: If you are testing for an input box accepting numbers from 1 to 1000
then there is no use in writing thousand test cases for all valid input numbers plus
other test cases for invalid data. Using equivalence partitioning method above test cases
can be divided into three sets of input data called as classes. Each test case is a
representative of respective class. So in above example we can divide our test cases into
three equivalence classes of some valid and invalid inputs.
Test cases for input box accepting numbers between 1 and 1000 using
Equivalence Partitioning.
1. One input data class with all valid inputs. Pick a single value from range 1 to
1000 as a valid test case. If you select other values between 1 and 1000 then result is
going to be some. So one test case for valid data should be sufficient.
2. Input data class with all values below 1, as a invalid input data test case.
3. Input data with any value greater than 1000 to represent third invalid input
class.
So using equivalence partitioning you have categorized all possible test cases into
three classes. Test cases with other values from any class should give you the same
result.
We have selected one representative from every input class to design our test cases.
Test case values are selected in such a way that largest number of attributes of
equivalence class can be exercised.
Equivalence partitioning uses fewest test cases to cover maximum requirements.
(b) Take any example of your choice and write down the number, of Test
cases.
Ans. Consider a program for the determination of the nature of roots of a quadratic
equation. Its input is a triple of positive integers (Say a, b, c) and values may be from
interval [0, 100]. The program output may have one of the following words.
[Not a quadratic equation Real roots; Imaginary roots, Equal roots]
Quadratic Equation will be of type:
ax2 + bx + c = 0
Roats are real if (b2 – 4 ac) > 0
Roots are imaginary if (b2 – 4 ac) < 0
Roots are equal if (b2 – 4 ac) = 0
Equation is not quadratic if a = 0
Total number of Test cases = 4n + 1
where n → number of inputs
= 4(3) + 1 = 13 Test cases
Boundary value test cases are given as:
1 0 50 50 Not Quadratic
2 1 50 50 Real Roots
3 50 50 50 Imaginary Roots
4 99 50 50 Imaginary Roots
5 100 50 50 Imaginary Roots
6 50 0 50 Imaginary Roots
7 50 1 50 Imaginary Roots
8 50 99 50 Imaginary Roots
9 50 100 50 Equal Roots
10 50 50 0 Real Roots Real
11 50 50 1 Roots Imaginary
12 50 50 99 Roots Imaginary
13 50 50 100 Roots