Beruflich Dokumente
Kultur Dokumente
Please bring a printed copy, or, if you have a long commute, submit it early enough so I can
print it.
1.
(10) This Spring, we switched to Daylight Savings time on March 7. Officially, this
switch occurred at 2:00 a.m. on Sunday morning, March 8, 2015, when clocks were reset to
3:00 a.m. Suppose you had to test a telephone call billing program that charges all calls
using the following rate structure:
Call Duration <= 20 minutes charged at $0.05 per each minute or fraction of a minute
Call Duration > 20 minutes charged at $1.00 plus $0.10 per each minute or fraction of a
minute in excess of 20 minutes.
Please use variables from this brief data dictionary in your discussion. (Note that I assume
the maximum call duration is 30 hours; this simplifies your analysis.)
Variable
CD
CST
Description
Call Duration
Call start time
Units
hour:min:sec
JulianDay:hour:min:sec
CET
Cost
JulianDay:hour:min:sec
US Dollars and cents
Range
0 - 30 hours
1<=JulianDay<=36
6
0<=hour<=23
0<=min<=59
0<=sec<=59
(same as for CST)
max Cost =
$179.00
if you chose a form of Boundary Value Testing, make a graph of your test cases.
2.
(10) Draw the program graph for the call charge procedure pseudocode given
below. What is its cyclomatic complexity?
Procedure callCharge1(cst, cet,cost)
Dim duration As Time
1.
round up seconds on cst
2.
round up seconds on cet
3.
If (cst < 97:02:00:00)'time change for 2015, March 7 (day 66)
4.
Then 'call starts in standard time
5.
If (cet <= 66:02:00)
6.
Then duration = cet - cst
'call ends in standard
time
7.
Else duration = (cet - cst
) - 00:01:00 'call ends in
daylight time
8.
EndIf
9.
Else
'call starts in daylight time
10.
If (cet > 66:03:00)
11.
Then duration = cet - cst
'call ends in daylight
time
12.
Else error message ("call ends in standard time
IMPOSSIBLE")
13.
EndIf
14.
EndIf
15.
If (duration <= 00:00:20)
16.
Then cost = $0.05 * duration
17.
Else cost = $1.00 + $0.10 * (duration - 00:00:20)
18. EndIf
19.
End Procedure callCharge1
3.
(10)
sequence
List distinct paths are in your graph. As a start, the path P1 follows the node
P1 = <1, 2, 3, 4, 5, 6, 8, 14, 15, 16, 18, 19>
4.
(10) Which of the paths you identified in Question 2 are traversed by the test cases
you postulated in Question 1?
5.
(10) E.F. Miller proposed the following test coverage metrics in his Ph.D. dissertation
in the mid-1970s:
C0
Every Statement
C1
Every DD-Path
C1p
Every predicate outcome
C2
C1 plus loop coverage
Cd
C1 plus every dependent pair of DD-Paths
CMCC
Compound condition coverage
Cik
Every program path that contains up to k (usually =2) loop repetitions
Cstat
Statistically significant fraction of paths
C
All possible execution paths
Our revised definition of a program graph mandates changes to some of these. In addition, if
we apply basic concepts of directed graphs, we can define better coverage metrics. Make
use of our definitions of indegree, outdegree, edge, chain, strong component, and path. Use
this definition and notation as a start.
Definition: Given a program P written in an imperative programming language, its program
graph G(P) is a directed graph in which nodes, n i, correspond to statement fragments, and
edges, ei, correspond to possible sequential execution of the statement fragments that mark
the originating and terminating nodes of an edge.
Use your knowledge of directed graphs to define a set of test coverage metrics; for
separation from Millers metrics, name yours Dx. As a start, consider (remember, I do the
easy parts!):
Given a set of test cases T for program P, where G(P) is the program graph of P, when the
set T is run on P, the coverage of T on P is defined by:
D0
6.
(5)
Relate your set of Dx coverage metrics to Millers set. (Dont worry about
Cstat .) As a start, you can say
D0 C0
7.
(5)
Express your coverage metrics as a lattice, and compare your lattice to the one above.
Make two copies of above example. Use one to show the backward slice of lockSales at node
24. (Just highlight the backward slice). Then use your second copy to show (and highlight)
the forward slice of lockPrice at node 7. Finally highlight the nodes for each of your slices.9.
(5)
Determine the cyclomatic complexity of this graph.
10.
(10)
Instrument the "integration version" of NextDate (begins on the next
page) so that, if the instrumented pseudo-code could be executed, you could find MM-Paths
"automatically". Your instrumentation should show just the message flow (calls and returns)
that you can derive from the pseudo-code. Dont worry about new statement numbers for
your instrumentation, but please, make it easily recognizable (e.g., bold or maybe red font)
Try out your instrumentation for April 22, 2015 (exam due date!). Show what your
instrumentation would print/write to a file.
Main proceduralNextDate
Type Date
'Integration Version
Month As Integer
Day As Integer
Year As Integer
EndType
Dim today As Date
Dim tomorrow As Date
2
3
4
5
6
GetDate(today)
PrintDate(today)
tomorrow = IncrementDate(today)
PrintDate(tomorrow)
End Main
7
8
9
10
11
12
13
14
15
16
17
18
19
20
Function isLeap(year)Boolean
If (year divisible by 4)
Then
If (year is NOT divisible by 100)
Then isLeap = True
Else
If (year is divisible by 400)
Then isLeap = True
Else isLeap = False
EndIf
EndIf
Else isLeap = False
EndIf
End (Function isLeap)
21
22
23
24
25
26
27
28
29
30
31
32
33
34
Function GetDate(aDate)
Date
dim aDate As Date
Function ValidDate(aDate) Boolean
'within scope of GetDate
dim aDate As Date
dim dayOK, monthOK, yearOK As Boolean
35
36
37
38
39
40
41
42
Then
If ((aDate.Day > 0) AND
(aDate.Day <=
lastDayOfMonth(aDate.Month, aDate.Year))
43
Then dayOK = True
44
Else dayOK = False
45
EndIf
46
EndIf
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
Function IncrementDate(aDate)
Date
If (aDate.Day < lastDayOfMonth(aDate.Month))
Then aDate.Day = aDate.Day + 1
Else aDate.Day = 1
If (aDate.Month = 12)
Then aDate.Month = 1
aDate.Year = aDate.Year + 1
Else aDate.Month = aDate.Month + 1
EndIf
EndIf
End (IncrementDate)
79
80
81
Procedure PrintDate(aDate)
Output( "Day is ", aDate.Month, "/", aDate.Day, "/", aDate.Year)
End (PrintDate)
11.
(5)
Explain why you can (or cannot) instrument the integration version to show
points of message quiescence?
12.
(10)
Compute how many mutations will be generated for the Visual Basic
Function isLeap when the following mutation operators are applied to the source code.
Arithemetic Operation Mutator:
Relational Operation Mutator:
Constant Mutator:
Connective Mutator:
Boolean Mutator:
Assignment Mutator
Variable Mutator
Variable Mutator
{+, -, *, /, %}
{<, <=, ==, !=, >=, >}}
{x, x+1, x-1}
{AND, OR, EOR}
{True, False}
{=, +=, -=}
{year, anno, Jahr}
{c1, d1, c2)
c1
year
c2
year
c3
isLea
p
year
Fals
e
4
10
0
40
0
NOT
c2
OR
c1
isLea
p
=
AN
D
=
True
=
=
=
=
=
=
c3
0
0
0
13. . (10)
formulation:
Develop operational profiles for the garage door controller. Use this
Input events
Output events
(actions)
States
e1: depress controller button
a1: start drive motor down
s1:
Door Up
e2: end of down track hit
a2: start drive motor up
s2: Door Down
e3: end of up track hit
a3: stop drive motor
s3: Door Stopped going down
e4: obstacle hit
a4: reverse motor down to
up s4: Door Stopped going up
e5: laser beam crossed
s5: Door Closing
On the next page there is a start to your spreadsheet. I did Use Case 1 for you. Use the use
cases as shown, and then develop the operation profile testing order. Be sure to show your
use case probabilities, and your operational testing order.
Path
/ Use
Case
1
Description
State Sequence
Normal close.
s1, s5, s2
s2, s6, s1
Normal open.
Close, stopped and
restarted.
Close, stopped and
restarted, stopped a second
time, and restarted.
Open, stopped and
restarted.
Open, stopped and
restarted, stopped a second
time, and restarted.
Close, obstacle sensed.
2
3
4
5
6
10
path
probabilit
y
0.8500
14.
(8)
This is an extension of the Garage Door Controller problem. The two safety
devices (light beam and obstacle sensor) can fail. Here we consider two common failure
modes: stuck at one and stuck at zero. Failure Mode Effects Analysis (FMEA) is a widely
accepted way to deal with such situations. The table below describes the effects of the
"stuck at" failure modes for each device. Each device is enabled when the garage door
begins to close. In normal operation, the devices are disabled when the garage door stops,
either partially or fully closed.
Enabled Safety
Device
Light Beam Sensor
Stuck at zero
Stuck at one
Obstacle Sensor
The hope of designers is that the safety devices never fail. The lawyers, however, have a
more cautious view, and correctly worry about lawsuits due to device malfunctions. For this
question, add your completed use cases to the operational profiles you developed for the
original ten use cases given earlier Take a closer look at the failure modes. We will postulate
four new events that can occur in state s5: Door Closing
e6: Obstacle encountered, sensor stuck at zero
e7: Obstacle sensor stuck at one
e8: Light beam interrupted, sensor stuck at zero
e9: Light beam sensor stuck at one
Complete the four new use cases, started here. Add additional rows for events if you need
them, and be sure to show the post-conditions.
Name, ID
Description
Preconditions
Postconditions
Name, ID
Description
Pre-
conditions
Event Sequence
Inputs
Outputs
1 e1: control device signal
2. a1: start drive motor down
3. e7: Obstacle sensor stuck at
one
Postconditions
Name, ID
Description
Preconditions
Postconditions
Name, ID
Description
Preconditions
Postconditions
15.
(12)
Device failure rates are usually very small. For this exercise, assume
that both the light beam sensor and the obstacle sensor have total failure rates of 0.0001;
stuck at 0 failures are more common than stuck at 1 failures. The four new events will have
VERY LOW probabilities, and these are given in the Table 12.1 below:
Table 12.1: "Stuck at" Probabilities
for the Safety Devices
Device
Stuck at 0
Stuck at 1
probability
probability
Obstacle Sensor
0.00006
0.00004
Light Beam Sensor
0.00008
0.00002
This is where the lawyers enter the picture. If a closing door fails to close when it should, the
garage might be left open for an entire working day, leaving the home vulnerable to massive
thefts, vandalism, or some other calamity. Similarly, if the garage door does not close when
it should, a pet, a child, or possibly some very fragile (and expensive) artifact could be
damaged. Any of these calamities would likely result in a very expensive lawsuit. This
question asks you to extend your operational profiles from question 11 to Risk-Based
Testing. To help with this, I provide the cost of failure penalties for each of the 12 use cases.
Add your completed use cases to the Operational Profiles you developed for Question 10,
and then use the given cost of failure penalties to produce the Risk-Based Testing profile.
Use cases 6 through 10 are replaced by the your new use cases. The (deliberately)
incomplete figure below may help you develop your path probabilities. Notice the new
transition probabilities, and the probabilities you need to add. (Note the new path
probabilities.)
Table 12.2 Operational Profiles for the Garage Door Controller (with FMEA use cases)
Path /
Use
Case
1
2
3
4
5
Description
State Sequence
Normal close.
s1, s5, s2
Normal open.
Close, stopped and
restarted.
Close, stopped and
restarted, stopped a
second time, and
restarted.
Open, stopped and
restarted.
s2, s6, s1
s1, s5, s3, s5, s2
path
probability
0.9400
Cost of
Failure
$600.
$100.
$600.
11
12
13
14
$100.
$600.
$200,000,00
0.
$600.
$300,000,00
0.
10
10
10
10
10
10
10
10
11
12
10
13
10
14
15
12
your score