Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

CODE COVERAGE

How many inputs are required for 100% Statement Coverage?


Read customer_name
Read record a. 1
If age < 18 then b. 2
1
Print Reject customer c. 3
Else d. 4
Print accept customer
Endif
Read A,B
If A>=2
Print A+B
else
a. SC=2,DC=2
Print A-B
b. SC=1,DC=3
2 Endif
c. SC=2,DC=3
If B<1
d. SC=3,DC=3
Print B-A
End
For the above algorithm what will be the minimum number of test cases required to achieve
100% Statement Coverage and Decision Coverage?
01 Input number of Sandwich
02 Input number of Iced tea a) Sandwich = 1, Iced tea = 1, home
03 If (Sandwich > 0 and Iced tea > 0) then delivery = yes
04 Input Do you want home delivery (Yes / No) b) Sandwich = 1, Iced tea = 1, home
05 If home delivery = No? delivery= no
3
06 Print Serve their order now c) Sandwich= 1, Iced tea = 2, home
07 End if delivery= yes
08 End If d) Sandwich= 1, Iced tea = 0, home
delivery = no
Which of the following test cases will ensure that statement 6 is executed?
How many inputs are required for 100% statement coverage?

Read customer_name
a) 1
Read record
b) 2
4 If age < 18 then
c) 3
Print Reject customer
d) 4
Else
Print accept customer
Endif
Which of the following is NOT true of test coverage criteria?

a) A measure of test coverage criteria is the percentage of user requirements covered.


5
b) Test coverage criteria can be measured in terms of items exercised by a test suite.
c) A measure of test coverage criteria is the percentage of faults found.
d) Test coverage criteria are often used when specifying test completion criteria.
6 Void main (int a, int b) a. SC=2,DC=2
{ b. SC=1,DC=3
If (a<b && a+b<20) c. SC=2,DC=3
{ d. SC=2,DC=3
Cout << “welcome to website”<<endl;
If (a*b > 50)
Cout <<”welcome to 4.com”<<endl;
}
CODE COVERAGE
Else
Cout <<”Thank you for your time on our website”<<endl;
}
7
IF A > B THEN
C=A–B
ELSE a) 1 test for statement coverage, 3 for branch coverage
C=A+B b) 2 test for statement coverage, 2 for branch coverage
8 ENDIF c) 2 test for statement coverage, 3 for branch coverage
READ D d) 3 test for statement coverage, 3 for branch coverage
IF C = D THEN e) 3 test for statement coverage, 2 for branch coverage
PRINT “ERROR”
ENDIF
Pick up & Read the newspaper
Look at what is on television SC = 1 & DC = 1
If there is a program that you are interested in watching then switch on the television watch SC = 1 & DC = 2
9 the program SC = 1 & DC = 3
Otherwise SC = 1 & DC = 2
Continue reading the newspaper SC = 1 & DC = 3
If there is a crossword in the newspaper then try & complete the crossword
10
Discount rate = 1;
Fare = 1000;
SC = 1 & DC = 2
If ((Person = “senior citizen”) & (“travel month = January”))
SC = 2 & DC = 2
11 Bonuspoints = 100 + Bonuspoints
SC = 1 & DC = 3
If (class = “first”)
SC = 2 & DC = 4
discountRate = 5;
Fare = fare * discountRate;
If width > length
Then
Biggest_dimension = width
If height > width
Then
Biggest_dimension = height SC = 1 & DC = 2
End_if SC = 2 & DC = 2
12
Else SC = 1 & DC = 3
Biggest_dimension = length SC = 2 & DC = 4
If height > length
Then
Biggest_dimension = height
End_if
End_if
Disc = 0
Order-qty = 0
Read Order-qty
SC = 1 & DC = 2
If Order-qty >= 20 then
SC = 2 & DC = 2
13 Disc = 0.05
SC = 1 & DC = 3
If Order-qty >= 100 then
SC = 2 & DC = 4
Disc = 0.1
End if
End if
14 Ask: “What type of ticket do you require, single or return?” SC = 2 & DC = 2
CODE COVERAGE
If the customer wants ‘return’
Ask: “What rate, Standard or Cheap-day?”
If the customer replies ‘Cheap-day’
Say: “That will be 500/-”
SC = 3 & DC = 3
ELSE
SC = 2 & DC = 3
Say: “That will be 1000/-”
SC = 3 & DC = 4
ENDIF
ELSE
Say: “That will be 800/-”
ENDIF
1. If x=3 then
2. Display_messageX;
3. If y=2 then SC = 2 & DC = 2
4. Display_messageY; SC = 3 & DC = 3
15
5. Else SC = 2 & DC = 3
6. Display_messageZ; SC = 3 & DC = 4
7. Else
8. Display_messageZ;
Which of the following is NOT a black box technique:
16
a) Equivalence partitioning b) State transition testing c) LCSAJ d) Syntax testing
Which of the following statements is NOT correct?
a) A minimal test set that achieves 100% LCSAJ coverage will also achieve 100% branch coverage.
b) A minimal test set that achieves 100% path coverage will also achieve 100% statement coverage.
17 c) A minimal test set that achieves 100% path coverage will generally detect more faults than one that achieves 100%
statement coverage.
d) A minimal test set that achieves 100% statement coverage will generally detect more faults than one that achieves
100% branch coverage.
The principle of Cyclomatic complexity, considering L as edges or links, N as nodes, P as independent paths.
18
A. L-N +2P B. N-L +2P C. N-L +P D. N-L +P
Cyclomatic Complexity method comes under which testing method.
19
a. White box b. Black box c. Green box d. Yellow box
The principle of Cyclomatic complexity, considering E as edges or links, N as nodes, P as Exit Points.
20
A. 2E-N +2 B. E-N -2P C. 2N-E +P D. E-N+2P
Q. 1054: For the code fragment given below, which answer correctly represents minimum
tests required for statement and branch coverage respectively?

Discount rate=1;
A. SC= 1, BC= 2
Fare = 1000;
21 B. SC= 2, BC= 2
If ((person == “senior citizen”) and (“travel month = January”))
C. SC= 1, BC= 3
Bonuspoints = 100+Bonuspoints
D. SC= 2, BC= 4
If (class==”first”)
discountRate = .5;
Fare = fare * discountRate;
22 How many test cases are needed to achieve 100 % statement coverage? A. 5
if ((temperature < 0) or B. 4
(temperature > 100)) { C. 2
alert (“DANGER”); D. 3
if ((speed > 100) and (load <= 50)) {
speed = 50;
}
} else {
check = false;
CODE COVERAGE
}
You have designed test cases to provide 100% statement and 100% decision coverage for the
following fragment of code.
if width > length
then
biggest_dimension = width
else
biggest_dimension = length
end_if

23 The following has been added to the bottom of the code fragment above.
print “Biggest dimension is ” & biggest_dimension
print “Width: ” & width
print “Length: ” & length
How many more test cases are required?
A. One more test case will be required for 100 % decision coverage.
B. Two more test cases will be required for 100 % statement coverage, one of which will be
used to provide 100% decision coverage.
C. None, existing test cases can be used.
D. One more test case will be required for 100″ statement coverage.
A white box testing technique that measures the number of or percentage of decision directions executed by the test
24 case designed is called
A. Condition coverage B. Decision/Condition coverage C. Decision Coverage D. Branch coverage
Statement Coverage will not check for the following.
25
A. Missing Statements B. Unused Branches C. Dead Code D. Unused Statement
How many test cases are needed to achieve 100 % decision coverage?
If (p = q) {
s = s + 1;
A. 3
if (a < S) {
B. 6
26 t = 10;
C. 5
}
D. 4
} else if (p > q) {
t = 5;
}
Cyclomatic complexity is used to calculate
A. Number of independent paths in the basis set of a program
B. Number of binary decisions + 1
27
C. Number bound for the number of tests that must be conducted to ensure that all statements have been executed
at least once
D. Number of branches and decisions
A program with high Cyclomatic complexity is almost likely to be:
28
A. Large B. Small C. Difficult to write D. Difficult to test
If a program is tested and 100% branch coverage is achieved, which of the following coverage
criteria is then guaranteed to be achieved?
29
A. 100% Equivalence class coverage B.100% Condition coverage, 100% Statement coverage
C. 100% Statement coverage D. 100% Multiple condition coverage
30
31
32
33
34
CODE COVERAGE
35
36
37
38
39
40

You might also like