Game Development Reference

In-Depth Information

paths. You may end up exiting some tests after only a few flows or you could travel around

the diagram quite a bit before reaching the OUT box. Normally you would generate the

random numbers as you need them, but for your convenience the random number set

for the example in this section is 30, 27, 35, 36, 82, 59, 92, 88, 80, 74, 42, and 13.

Generating a test case for the TFD in Figure 12.16 starts at the IN box. The only flow

from there has a 100% usage so there is no need to produce a random number—you

must begin your test with this flow. Next, there are two possible ways out from the

NoPointsItemLocked
state: flow 3 and flow 14. Each of those flows has the usage proba-

bility of 50%. Assign them each a random number range according to their numerical

order. Use flow 3 if the random number is 1-50 and use flow 14 if it is 51-100. Get the

random number 30 from the list above and take flow 3 to
HavePointsItemLocked
. The test

path so far is 1, 3.

There are two flows exiting state
HavePointsItemLocked
. Flow 2 has a 10% usage and flow

4 has a 90% usage. The range for flow 2 is 1-10 and for flow 4 it's 11-100. Use 27 as

the random number for this flow. That sends the test along flow 4 to

HavePointsItemUnlocked
. The test path at this point is 1, 3, 4.

HavePointsItemUnlocked
is the most interesting state so far, with four flows to choose

from for the next step in your test. Flow 5 has a 5% usage, flow 6 has 10%, flow 7 has

75%, and flow 12 has 10%. The corresponding number ranges are 1-5 for flow 5, 6-15

for flow 6, 16-90 for flow 7, and 91-100 for flow 12. You anxiously await the next ran-

dom number…and it's…35. Your test path now takes flow 7 to
NoPointsHaveItem
.The

path is now 1, 3, 4, 7.

From
NoPointsHaveItem
there are two flow choices: flow 8 with a 10% usage and flow 9

with a 90% usage. You will take flow 8 if the random number is in the range 1-10 and

flow 9 if it's within 11-100. Your new random number is 36, so take flow 9 to

NoPointsItemUnlocked
. The test path is currently 1, 3, 4, 7, 9.

Flows 10, 11, and 13 all leave
NoPointsItemUnlocked
. Flow 10's usage is 5% (1-5), flow 11

has a 90% usage (6-95), and flow 13 has a 5% (96-100) usage. Another random num-

ber is generated and it's 82. That's within the range for flow 11, so take that flow to

HavePointsItemUnlocked
. The path has grown to 1, 3, 4, 7, 9, 11, but you're not done yet.

You're back at
HavePointsItemUnlocked
and the next random number is 59. That fits in

the 16-90 range for flow 7, taking you on another trip to
NoPointsHaveItem
. A usage of

92 here matches up with flow 9, going to
NoPointsItemUnlocked
. The test path is now 1,

3, 4, 7, 9, 11, 7, 9.

The next random number is 88. This takes you from
NoPointsItemUnlocked
to

HavePointsItemUnlocked
via flow 11. The 80 takes you along flow 7 for the third time in