APPENDIX D − SOLUTIONS TO THE EXERCISES

E5.1 Identify the EPs and one ON, OFF and IN/OUT point for each EP in the following specification.

Payment: for online shopping, the shipment fee is the following. If the final price is below EUR 50, then the shipment is not possible. If the price is below EUR 100, then the shipment fee is 10 per cent of the final price, in the case where the price is below EUR 500 the shipment fee is five per cent, and if the price reaches or exceeds EUR 500, the shipment is free. If the weight surpasses 10 kg, then EUR 1 is paid for each kilogram (where weight is rounded up to the next integer). Finally, if the shipment comes from abroad, the extra fee is doubled except for neighbouring countries, where the extra fee is only 1.5 times more. The price shift is EUR 0.1; the minimum non-zero weight shift is 0.1 kg. No negative or non-numeric cases should be considered.

Solution: In Table D.1 the ON1/OFF1/IN1 point is related to the lower border of an interval, while the ON2/OFF2/OUT2 point is related to the upper border of the same interval, for example for ≥50 – <100, ON1 relates to 50 and ON2 relates to 100. As during online shopping, the prices are given when an item is selected. We will consider neither negative nor non-numeric prices.

Table D.1 Equivalence partitions for solving Exercise 5.1

image

An alternative solution is shown in Table D.2.

Table D.2 Equivalence partitions for solving Exercise 5.1 – an alternative

image

image

E5.2 Produce a test design for the specification above.

As the weight is rounded, it may occur that the weight is zero, yet the price is EUR 50 (consider a valuable stamp for example).

Table D.3 BVA for solving Exercise 5.2

image

E6.1 Construct test paths applying the all-transition–transition criterion for ‘TVM ticket selection’ (see Figure 6.7).

Let’s consider the following six paths:

Tpath1= s1-t1-s2-t7-s2-t10-s2-t4-s1-t1-s2-t7-s2-t10-s2-t4-s1-t2-s3-t8-s3-t11-s3-t5-s1-t3-s4-t9-s4-t12-s4-t6-s1-t3-s4-t15-s5

Tpath2 = s1-t2-s3-t8-s3-t11-s3-t5-s1-t2-s3-t8-s3-t11-s3-t5-s1-t3-s4-t9-s4-t12-s4-t6-s1-t1-s2-t7-s2-t10-s2-t4-s1-t1-s2-t13-s5

Tpath3 = s1-t3-s4-t9-s4-t12-s4-t6-s1-t3-s4-t9-s4-t12-s4-t6-s1-t1-s2-t7-s2-t10-s2-t4-s1-t2-s3-t8-s3-t11-s3-t5-s1-t2-s3-t14-s5

Tpath4 = s1-t1-s2-t13-s5

Tpath5 = s1-t2-s3-t14-s5

Tpath6 = s1-t3-s4-t15-s5

Then

(t1,T), (t4, T), (t7, T), (t10, T) satisfy for all T ϵ {t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t15} in Tpath1, T = t13 in Tpath2 and T = t14 in Tpath3.

(t2, T), (t5, T), (t8, T), (t11, T) satisfy for all T ϵ {t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13} in Tpath2, T = t15 in Tpath1 and T = t14 in Tpath3.

(t3, T), (t6, T), (t9, T), (t12, T) satisfy for all T ϵ {t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t14} in Tpath3, T = t15 in Tpath1 and T = t13 in Tpath2.

On the other hand,

(!t1, T), (!t4, T), (!t7, T), (!t10, T), (!t13, T) satisfy for all T ϵ {t2, t3, t5, t6, t8, t9, t11, t12} in Tpath2, T = t14 in Tpath5 and T = t15 in Tpath6 (there are no other possibilities).

(!t2, T), (!t5, T), (!t8, T), (!t11, T), (!t14, T) satisfy for all T ϵ {t1, t3, t4, t6, t7, t9, t10, t12} in Tpath3, T = t13 in Tpath4 and T = t15 in Tpath6 (there are no other possibilities).

(!t3, T), (!t6, T), (!t9, T), (!t12, T), (!t15, T) satisfy for all T ϵ {t1, t2 t4, t5, t7, t8, t10, t11} in Tpath1, T = t13 in Tpath4 and T = t14 in Tpath5 (there are no other possibilities).

(!t4, t13), (!t7, t13), (!t10, t13) in Tpath4.

(!t5, t14), (!t8, t14), (!t11, t14) in Tpath5.

(!t6, t15), (!t9, t15), (!t12, t15) in Tpath6.

Hence, the all-transition–transition criterion is satisfied.

E6.2 Ordering water from an online shop. The types of water can be still or sparkling. We can buy bottles of one type only. If nothing is selected, then the quantity of either of them can be increased. After one has been selected, only one of the water types with a non-zero amount can be increased or decreased by one. The maximum number of bottles to be ordered is five. If the selected number of bottles is greater than 0, then the buying process can start. The output is the type and number of the selected bottles.

Model the buying process with a state transition graph and design tests for the following test selection criteria:

1. all-transition criterion;

2. all-2-transitions criterion;

3. all-transition-state criterion.

Precondition: the web page shows the initial screen where the buying process can start. The number of bottles is set to zero (NrB := 0) and the water type is empty (WaterType := ‘’).

States:

s1: initial state;

s2: still water selection;

s3: sparkling water selection;

s4: payment.

Input:

e1: increasing the number of still water bottles (inc-still);

e2: increasing the number of sparkling water bottles (inc-spark);

e3: decreasing the number of still water bottles (dec-still);

e4: decreasing the number of sparkling water bottles (dec-spark);

e5: selecting for payment (pay).

Output (actions)

a1: increment the number of still water bottles (still+);

a2: increment the number of sparkling water bottles (spark+);

a3: decrement the number of still water bottles (still-);

a4: decrement the number of sparkling bottles (spark-);

a5: goes to the payment screen (payment) and passes the global data value NrB.

Transitions:

t1: inc-still / still+;

t2: dec-still / [NrB = 1] / still-;

t3: inc-spark / spark+;

t4: dec-spark / [NrT = 1] / spark-;

t5: inc-still / [NrB < 5] / still+;

t6: dec-still / [NrB > 1] / still-;

t7: inc-spark / [NrB < 5] / spark+;

t8: dec-spark / [NrB > 1] / spark-;

t9: pay / <a5, WaterType := ‘Still’>;

t10: pay / <a5, WaterType := ‘Sparkling’>.

Figure D.1 STT for solving Exercise 6.2

image

1. All-transition criterion:

The following two tests paths are enough:

Tpath1 = s1-t3-s3-t4-s1-t1-s2-t5-s2-t6-s2-t9-s4

Tpath2 = s1-t1-s2-t2-s1-t3-s3-t7-s3-t8-s3-t10-s4

2. All-2-transitions criterion (for simplicity only the transitions are shown):

Tpath1 = t3-t4-t1-t5-t5-t6-t6-t5-t9

Tpath2 = t1-t5-t6-t2-t1-t5-t6-t9

Tpath3 = t1-t2-t3-t4-t1-t9

Tpath4 = t1-t2-t3-t7-t7-t8-t8-t7-t10

Tpath5 = t3-t7-t8-t4-t3-t7-t8-t10

Tpath6 = t3-t4-t1-t2-t3-t10

These tests contain all the valid 2-transitions:

t1-t2, t1-t5, t1-t9, t2-t3, t2-t1, t5-t5, t5-t6, t5-t9, t6-t6, t6-t5, t6-t2, t6-t9,

t3-t4, t3-t7, t3-t10, t4-t1, t4-t3, t7-t7, t7-t8, t7-t10, t8-t4, t8-t7, t8-t10, t8-t8

Note that there are some invalid 2-transitions: t1-t6, t5-t2, t3-t8, t7-t4.

3. All-transition-state criterion

The following four tests paths are enough:

Tpath1 = s1-t1-s2-t2-s1-(t2-s1)-t2-s2-t5(5X)-s2-t6(4X)-s2-t2-s1-t3-s3-t4-s1-t3-s3-t10-s4

Tpath2 = s1-t3-s3-t4-s1-(t4-s1)-t2-s3-t7(5X)-s3-t8(4X)-s3-t3-s1-t1-s2-t2-s1-t1-s2-t9-s4

Tpath3 = s1-t1-s2-t9-s4

Tpath4 = s1-t3-s3-t10-s4

where (t2-s1) and (t3-s1) means the trial to decrease the number of water below 0.

(t1,S), (t2,S), (t5,S), (t6,S), satisfy for all S ϵ {s1,s2,s3,s4} in Tpath1, (t9,s4) in Tpath2.

(t3,S), (t4,S), (t7,S), (t8,S), satisfy for all S ϵ {s1,s2,s3,s4} in Tpath2, (t10,s4) in Tpath2.

All the avoidable transitions (t2, t3, t4, t5, t6, t7, t8, t10) for s2, s4 excluded in Tpath3.

All the avoidable transitions (t1, t2, t4, t5, t6, t7, t8, t9) for s3, s4 excluded in Tpath4.

Tpath3 and Tpath4 are also appropriate for excluding all (ti, s1) pairs.

Boundary value of the guard condition is reached: t5(5X)-s2-t6(4X)-s2-t2-s1 and -t7(5X)-s3-t8(4X)-s3-t3-s1

E7.1 Assignment

Consider the following specification.

A university course registration software assigns labs for the informatics faculty courses based on the number of registered students and the required software toolchains. There are three common toolchains used in teaching: GNU toolchain, Apache-Maven tool-chain, and SharePoint Framework toolchain. There are four labs of different sizes (with a different number of computers) in the faculty.

1. If the number of registered students for a course is fewer than 10 and Apache-Maven is needed, then the course will be in lab A.

2. If the number of registered students for a course is between 10 and 30 and Apache-Maven toolchain is needed, then the course will be in lab B.

3. If the number of registered students for a course is fewer than 10 and GNU or SharePoint is needed, then the course will be in lab B.

4. If the number of registered students for a course is between 10 and 30 and GNU is needed, then the course will be in lab C.

5. If the number of registered students for a course is above 30, or between 10 and 30 with SharePoint requirement, then the course will be in lab D.

Model and design tests for the software.

We use the following notations:

Category 1 (C1): The number of registered students is fewer than 10.

Category 2 (C2): The number of registered students is between 10 and 30.

Category 3 (C3): The number of registered students is above 30.

Table D.4 Decision table for solving Exercise 7.1

image

Possible test suite:

TC1 = ([toolchain = GNU, student number = 9], [Lab = B])

TC2 = ([toolchain = GNU, student number = 10], [Lab = C])

TC3 = ([toolchain = Apache-Maven, student number = 9], [Lab = A])

TC4 = ([toolchain = Apache-Maven, student number = 30], [Lab = B])

TC5 = ([toolchain = Sharepoint, student number = 9], [Lab = B])

TC6 = ([toolchain = Sharepoint, student number 10], [Lab = D])

TC7 = ([student number = 31], [Lab = D])

E7.2 Police control rules.

A police department has specific rules that should apply in for on-road control. Measuring the speeds of all the passing cars, the police officer stops a car to check the driver’s licence, vehicle registration, and the driver’s alcohol level. If there are licence problems (it is non-existent or expired), a of EUR 350 penalty should be given, and the car is confiscated. In cases where the alcohol level is not zero, the penalty is EUR 300, the driver’s licence is withdrawn, and the car is confiscated. If the vehicle is unregistered or the registration is expired, the penalty is EUR 200. If the driver has exceeded the speed limit by less than or equal to 10 per cent, the penalty is EUR 50. If the speed limit was exceeded by more than 10 per cent, but less than or equal to 20 per cent the penalty is EUR 100; above 20 per cent the penalty is EUR 200. Note that the penalties are added together. If the car is not confiscated, then the police officer returns all the documents and the driver can leave in the car.

Design tests for this specification based on the decision table technique.

We use the following notations:

Category A: Speed limit exceeded by less than or equal to 10%.

Category B: Speed limit exceeded by more than 10%, but less than or equal to 20%.

Category C: Speed limit exceeded by more than 20%.

Category N: Otherwise.

The 32 test cases can easily be created based on Table D.5, for example:

TC15 = ([Licence problems = N, Registration problems = N, non-zero alcohol level = Y, speed limit exceeded = 11], penalty = 400, car confiscated = Y, licence is withdrawn = Y])

Table D.5 Decision tables for solving Exercise 7.2

image

image

E8.1 Consider the specification of E7.2. Design tests by applying use case testing.

For simplicity we denote steps 1–4 as I and 9–10 as X. Covering an exception (5E or 7E) the process stops before the last step (10). The test cases are shown in Table D.6.

Table D.6 Use case for solving Exercise 8.1

image

image

image

T1 = I-5-6-7-8- X    – happy path

T2 = I-5E-6-7-8

T3 = I-5E-6A-7-8

T4 = I-5E-6-7E-8

T5 = I-5E-6-7-8A-1

T6 = I-5E-6-7-8A-2

T7 = I-5E-6-7-8A-3

T8 = I-5-6A-7-8-X

T9 = I-5-6A-7E-8

T10 = I-5-6A-7-8A-1-X

T11 = I-5-6A-7-8A-2-X

T12 = I-5-6A-7-8A-3-X

T13 = I-5-6-7E-8

T14 = I-5-6-7E-8A-1

T15 = I-5-6-7E-8A-2

T16 = I-5-6-7E-8A-3

T17 = I-5E-6A-7E-8

T18 = I-5-6A-7E-8A-1

T19 = I-5-6A-7E-8A-2

T20 = I-5-6A-7E-8A-3

T21 = I-5E-6-7E-8A-1

T22 = I-5E-6-7E-8A-2

T23 = I-5E-6-7E-8A-3

T24 = I-5E-6A-7-8A-1

T25 = I-5E-6A-7-8A-1

T26 = I-5E-6A-7-8A-1

T27 = I-5-6-7-8A-1-X

T28 = I-5-6-7-8A-2-X

T29 = I-5-6-7-8A-3-X

T30 = I-5E-6A-7E-8A-1

T31 = I-5E-6A-7E-8A-2

T32 = I-5E-6A-7E-8A-3

The number of tests grows exponentially, because of the test selection criterion ‘all path coverage’. We can select a simpler set in which some paths are tested together: (T1, T2, T8, T13, T27, T28, T29, T30, T31, T32). Now we have only 10 tests.

As the test cases are created based on the graph, obviously any graph-based test selection criteria can be chosen, and thus, control the number of test cases.

We can also apply defect prevention to improve the specification, which may modify the test cases.

E8.2 Consider the specification of E7.2. Design five important user stories based on it.

Scenario: My licence expired

Given The police stopped my car

When My licence has expired

Then I shall pay EUR 350 penalty

And My car is confiscated

Scenario: I drank some alcohol

Given The police stopped my car

When My alcohol level is not zero

Then I shall pay EUR 300 penalty

And My driver’s licence is involved

And My car is confiscated

Scenario: I exceed the speed limit by a little bit

Given The police stopped my car

When I exceeded the speed limit by less than 10%

Then I shall pay EUR 50 penalty

Scenario: I exceed the speed limit by more than 10%

Given The police stopped my car

When I exceeded the speed limit by at least 10% and no more than 20%

Then I shall pay EUR 100 penalty

Scenario: I exceed the speed limit by at least 20%

Given The police stopped my car

When I exceeded the speed limit by at least 20%

Then I shall pay EUR 200 penalty

E9.1 Consider the specification of E5.1 (Payment). Design test cases by applying the diff-pair testing technique.

We start from the EP and BVA test cases and add those required for diff-pair testing. As the weight is rounded it may occur that a product with ‘zero’ weight can cost EUR 50 (consider a valuable stamp) (Table D.7).

E9.2 You want to test your favourite word processor. You are interested in the following attributes in combination:

fonts: Arial, Calibri, Cambria, Comic, Courier, Times New Roman, Verdana (7 types);

style: regular, italic, bold, bold italic (4 types);

size: 8, 9, 10, 12, 14, 16, 18, 20, 24, 28 (10 types);

effect: strikethrough, double strikethrough, superscript, subscript, small caps, all caps, hidden (7 types).

Construct test cases for pairwise testing.

Table D.7 Diff-pair tests for solving Exercise 9.1

image

Figure D.2 Parameter selection demonstration for Exercise 9.2

image

The test cases in Table D.8 cover the pairwise criteria.

Table D.8 Pairwise testing for Exercise 9.2

image

image

image

image

E10 Let’s extend our exploratory test cases with those related to the hardware of TVM including the testing of correct coins, banknotes and so on. Write the test cases in a similar way to how we have done it for the TVM example.

Buy a maximum number of tickets of different types and check that all the tickets are printed.

Insert different non-euro coins and validate that these coins are non-acceptable and will be given back.

Select a maximum number of 24-hour tickets, and insert a €100 banknote to check that it is not acceptable.

Insert some non-euro banknotes and validate that these banknotes are non-acceptable and will be given back.

Take out coins and banknotes from the machine so that there is not sufficient to refund the customer during an applicable transaction. Validate that the machine changes to the reduced mode by performing that transaction.

Buy some tickets to increase the supply of coins and banknotes in the machine. Validate that the machine changes back to normal mode.

Unplug the machine during a transaction, when some money has already been inserted. Validate that the machine stored the amount and it can be refunded.

Buy 10 tickets, and unplug the machine during the printing of the fifth ticket. Validate that the machine stored this failure and knew that only four tickets had been successfully printed.

E11 Consider the state transition graphs in Figures 11.2 and 11.3. Create test paths to satisfy the all-transition-state criterion by applying the reduced approach.

The simple test cases containing no avoidable transitions are the following:

Tp1 = s1-t1-s2-t4-s4-t8-s5

Tp2 = s1-t2-s3-t5-s4-t8-s5

Tp3 = s1-t3-Sub-t6-s4-t8-s5

We can see the symmetry for the states s2/s3/Sub, therefore we design test cases to cover pairs (t1/t4/t7, S), where S involves all the states:

Tp4 = s1-t1-s2-t4-s4-t7-s1-t1-s2-t4-s4-t8-s5

Tp5 = s1-t1-s2-t4-s4-t7-s1-t2-s3-t5-s4-t8-s5

Tp6 = s1-t1-s2-t4-s4-t7-s1-t3-Sub-t6-s4-t8-s5

For t2/t5 and t3/t6 we have the symmetric test paths below:

Tp7 = s1-t2-s3-t5-s4-t7-s1-t1-s2-t4-s4-t8-s5

Tp8 = s1-t2-s3-t5-s4-t7-s1-t2-s3-t5-s4-t8-s5

Tp9 = s1-t2-s3-t5-s4-t7-s1-t3-Sub-t6-s4-t8-s5

Tp10 = s1-t3-Sub-t6-s4-t7-s1-t1-s2-t4-s4-t8-s5

Tp11 = s1-t3-Sub-t6-s4-t7-s1-t2-s3-t5-s4-t8-s5

Tp12 = s1-t3-Sub-t6-s4-t7-s1-t3-Sub-t6-s4-t8-s5

We can see that Sub is covered seven times. This means that we can cover all the transitions in it (no backward edge is in Sub). Therefore, the reduced approach results in 12 test cases.

E12.1 Consider the feature presented in E6.2. Create the extended Gherkin model for this feature by applying all-transition-state criterion.

The key part here is to create the categories and the choices. One possible solution is the following:

Categories

handle still(I): increase; decrease; increase 5X; decrease 4X; buy

handle sparkling(I): increase; decrease; increase 5X; decrease 4X; buy

possibilities(O): increase/decrease still; decrease still; increase both; increase/decrease sparkling; decrease sparkling; buy still; buy sparkling

number of still(O): 0; 1; 5

number of sparkling(O): 0; 1; 5

The AC can be the following (we used sub-AC):

AC

happy still(ONLY):

WHEN handle still IS increase

WHEN handle still IS buy

THEN possibilities IS buy still AND number of still IS 1

happy sparkling(ONLY):

WHEN handle sparkling IS increase

WHEN handle sparkling IS buy

THEN possibilities IS buy sparkling AND number of sparkling IS 1

long still(ONLY):

WHEN handle still GOES increase; decrease; increase; increase 5X; decrease 4X; decrease; decrease

THEN possibilities GOES increase/decrease still; increase both; increase/decrease still; decrease still; increase/decrease still; increase both; increase both;

AND number of still GOES 1; 0; 1; 5; 1; 0; 0

long sparkling(ONLY):

WHEN handle sparkling GOES increase; decrease; increase; increase 5X; decrease 4X; decrease; decrease

THEN possibilities GOES increase/decrease sparkling; increase both; increase/decrease sparkling; decrease sparkling; increase/decrease sparkling; increase both; increase both;

AND number of sparkling GOES 1; 0; 1; 5; 1; 0; 0

long still and happy sparkling(ONLY):

WHEN long still WHEN happy sparkling

short still(ONLY):

WHEN happy still

long sparkling and happy still(ONLY):

WHEN long sparkling WHEN happy still

short sparkling(ONLY):

WHEN happy sparkling

E12.2 Consider E5.1 ‘Payment’. Create the extended Gherkin model of this specification.

Categories

Price(I): 0; 49.9; 50; 99.9; 100; 499.9; 500; 10,000

Weight(I): 0; 10; 10.1; 100

Shipment(I): local; abroad; neighbour

Shipment possible(O): yes; no

Payment(O): 0; 49.9; 55; 119.88; 107.5; 535.9; 500; 10,011

AC

Payment table:

WHEN Price IS 0 | 49.9 | 50 | 99.9 | 100 | 499.9 | 500 | 10,000

AND Weight IS 0 | 10 | 0 | 10 | 10 | 10.1 | 10 | 10.1

AND Shipment IS local | local | local | abroad | neighbour | local | local | local

THEN Shipment possible IS no | no | yes | yes | yes | yes | yes | yes

AND Payment IS 0 | 49.9 | 55 | 119.88 | 107.5 | 535.9 | 500 | 10,011

Test cases:

Payment table [0]:

Price(I) = 0, Weight(I) = 0, Shipment(I) = local, Shipment possible(O) = no, Payment(O) = 0

Payment table [49.9]:

Price(I) = 49.9, Weight(I) = 10, Shipment(I) = local, Shipment possible(O) = no, Payment(O) = 49.9

Payment table [50]:

Price(I) = 50, Weight(I) = 0, Shipment(I) = local, Shipment possible(O) = yes, Payment(O) = 55

Payment table [99.9]:

Price(I) = 99.9, Weight(I) = 10, Shipment(I) = abroad, Shipment possible(O) = yes, Payment(O) = 119.88

Payment table [100]:

Price(I) = 100, Weight(I) = 10, Shipment(I) = neighbour, Shipment possible(O) = yes, Payment(O) = 107.5

Payment table [499.9]:

Price(I) = 499.9, Weight(I) = 10.1, Shipment(I) = local, Shipment possible(O) = yes, Payment(O) = 535.9

Payment table [500]:

Price(I) = 500, Weight(I) = 10, Shipment(I) = local, Shipment possible(O) = yes, Payment(O) = 500

Payment table [10,000]:

Price(I) = 10,000, Weight(I) = 100, Shipment(I) = local, Shipment possible(O) = yes, Payment(O) = 10,011

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
52.14.168.56