• Keine Ergebnisse gefunden

Testing and Object Design Exercise

N/A
N/A
Protected

Academic year: 2022

Aktie "Testing and Object Design Exercise"

Copied!
2
0
0

Wird geladen.... (Jetzt Volltext ansehen)

Volltext

(1)

Chair for Applied Software Engineering Prof. B. Brügge, Ph. D.

Software Engineering Exercise, SoSe 2009 Exercise 4 - (due May 20th)

1/2

Testing and Object Design Exercise

A control flow graph is a special form of a UML state diagram. It can be used to visualize the control flow in source code. Every instruction is a state and the states are associated by directed successor edges. Figure 1 shows an example of a control flow graph and its source code. For readability all states that do not have multiple successor states are collapsed into one state. E.g., in Figure 1 state B represents the statements a++ and b++.

Figure 1

Control flow graphs are useful also to visualize and reflect on the different coverage metrics of whitebox testing. If you assign names to the edges you can also define test cases on the control flow graph by specifying a sequence of edge names.

1) Control flow graph

Draw a control flow graph for the following source code:

While (a<3) { if (b<1) {

c++;

}

if (a>b) { b=a;

}

else if (c==3) { c++;

}

else { a++;

} }

2) Test cases on control flow graphs a) Design

Design a test case for the control for graph of 1) using the assigned numbers that has a statement coverage of 100%.

(2)

Chair for Applied Software Engineering Prof. B. Brügge, Ph. D.

Software Engineering Exercise, SoSe 2009 Exercise 4 - (due May 20th)

2/2 Hint: You can design a test case on a control flow graph by specifying a sequence of edges.

Statement coverage (a.k.a. line coverage): Percentage of statements in the source code that are executed when running the tests.

b) Implementation

What values do you need to assign to parameters a, b and c to implement the test case you designed?

3) Statement vs. branch coverage

Find an example, where branch coverage is different from statement coverage. Write the source code and define a test case in terms of sequence of instructions that conforms to your source code. Also draw a control flow graph for your code.

Branch coverage: Percentage of the branches in the control flow graph that are taken when running the tests.

4) Condition coverage vs. branch coverage

Find an example and define the control flow graph and a test case for it where condition coverage is lower than branch coverage.

Hint: To specify a test case for condition coverage you should not only define the sequence of edges but also the assignment of the atomic boolean expressions for branching.

(Simple) Condition coverage: Percentage of atomic boolean expressions that are assigned true and false when running the test cases.

5) Path coverage

Under which conditions is it possible to reach 100% path coverage for a program containing a for-loop?

Path coverage: Percentage of all possible statement sequences when executing the code

6) Calculating your test coverage

For your test case for the weak phrase validator determine your statement, branch and condition coverage.

Hand in your printed or hand-written solutions in the next exercise.

Referenzen

ÄHNLICHE DOKUMENTE

In short, crucial relationships of similarity and difference are embedded in such tests of the user and unless such relationships can be contested, one particular

In this case study we compare cloud fractional cover measured by radiometers on polar satellites (AVHRR) and on one geostationary satellite (SEVIRI) to ground-based manual (SYNOP)

as long as analysis can be provided which demonstrates that the coverage analysis conducted at the object code will be equivalent to the same coverage analysis at the source

Our algorithm for the calculation of test case priorities is based on the sum of weight and potential values that have been assigned to the conditions and events in a

The union of the sets of FCESs of the minimal total length to cover the FESs of a re- quired length is called Minimal Spanning Set of Faulty Complete Event Sequences (MS 2 FCES)..

Cash transfers in low- and middle-income countries have improved the uptake of health services and outcomes (Ranganathan and Mylene Lagarde 2012) and school attendance (Robertson

The SARS epidemic was not simply a public health problem, but rather the most severe socio-political crisis for Chinese leaders since the June 4 th 1989 Tiananmen Square

As a consequence, a large part of time and effort spent on this dissertation involved taking decisions about individual entries of a collection of about 8000 verbs on the basis