Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

CE/CS/SE 3354 Software Engineering 4 question code is at bottom of the page 5. F

ID: 3914205 • Letter: C

Question

CE/CS/SE 3354 Software Engineering 4 question code is at bottom of the page

5. For the following program P3 written in pseudo-code, given the test set T:
T = {t1 = <-5, 2>, t2 = <3, 1>, t3 = <9, 3>}


a) What is the domain for statement coverage of P3? Note: do not include syntactical
markers such as comments, {, }, else, begin,
end.


b) What is the statement coverage for T?


c) What test cases (if any) should you add to T to provide 100% statement coverage?


d) What is the domain for decision coverage of P3?

When measuring test coverage, normally coverage is expressed as a percentage. It can also be
expressed as a fraction, and using an un-simplified fraction is preferred for this assignment.
Note that when adding test cases, there are many possible test cases that satisfy the objective:
provide 100% coverage for a given test criterion.

Program P3
1) integer A, B, C;
2) input (A, B);
3) if (A<-8 or A>8 or B<0 or B>3)
4) {
5) output (“Boundary condition failure on inputs.”);
6) }
7) else // valid input
8) {
9) C = A * B;
10) if (A < 0)
11) {
12) C = C + A + B;
13) if (B > 1)
14) {
15) C = C + 3;
16) } // end if (B>1)
17) C = C * C;
18) } // end if (A<0)
19) else
20) {
21) C = C – A – B;
22) if (B == 1)
23) {
24) C = B * C;
25) } // end if (B=1)
26) else
27) {
28) C = B / C;
29) } // end else !(B=1)
30) C = C + 2;
31) } // end else !(A<0)
32) output (A, B, C);
33) } // end else valid input
34) return 0;
35) end;

Explanation / Answer

Hi,

Please find the answers below:

a) What is the domain for statement coverage of P3?

Answer:

Domain for Statement coverage of P3 would include all the lines which would be possibly executed
that do not include syntactical markers such as comments, {, }, else, begin, end etc

Let the set be called DS

DS = {2,3,5,9,10,12,13,15,17,21,22,24,28,30,32}

b) What is the statement coverage for T?
Given the test set T:
T = {t1 = <-5, 2>, t2 = <3, 1>, t3 = <9, 3>}

Answer:

Calculate the statement coverage for individual testcases and take Union of the set.

t1 = <-5, 2> = {2,3,9,10,12,13,15,17,32}

t2 = <3, 1> = {2,3,9,10,21,22,24,30,32}

t3 = <9, 3> = {2,3,5}

Let the set be called TS.Take the Union of the sets

Statement coverage for TS ={2,3,5,9,10,12,13,15,17,21,22,24,30,32}

c) What test cases (if any) should you add to T to provide 100% statement coverage?

Answer:
Find what statements are not covered
i.e

DS - TS = {28}

Think of the logic of how 28th statement would be executed. This will give you a clue about the missing test case data.
Any test data which statisfies the below would be a condidate test case for missing test case:


!(B=1) AND !(A<0) AND NOT ( (A<-8 or A>8 or B<0 or B>3) )

For example: t= <7, 2> would make 100% statement coverage.

Note that I have removed statements 1, 34 which are executed for all.

d.What is the domain for decision coverage of P3?

The domain for decision coverage is the set of all possible decisions in the program under test. i.e P3

DC= {3,10,13,22}

Hope this is helpful. Let me know if you need more information on this.