Dynamic Black-Box Testing Part 2 How to reduce the number of test cases using: Decision Tables State...

20
Dynamic Black-Box Testing Part 2 • How to reduce the number of test cases using: Decision Tables State Transition

Transcript of Dynamic Black-Box Testing Part 2 How to reduce the number of test cases using: Decision Tables State...

Page 1: Dynamic Black-Box Testing Part 2 How to reduce the number of test cases using: Decision Tables State Transition.

Dynamic Black-Box TestingPart 2

• How to reduce the number of test cases using:• Decision Tables• State Transition

Page 2: Dynamic Black-Box Testing Part 2 How to reduce the number of test cases using: Decision Tables State Transition.

Black-box Testing

• There are four specification-based or black-box techniques:– Equivalence partitioning– Boundary value analysis– State transition testing– Decision tables

Focused on business logic or business rules.

Page 3: Dynamic Black-Box Testing Part 2 How to reduce the number of test cases using: Decision Tables State Transition.

State Transition Testing

• A black box test design technique in which test cases are designed to execute valid and invalid state transitions

• Finite state system: system where you get a different output for the same input, depending on what has happened before

• Shown as a state diagram

Page 4: Dynamic Black-Box Testing Part 2 How to reduce the number of test cases using: Decision Tables State Transition.

State Testing

• A software state is a condition or mode that the software is currently in

• A software tester must test a program's states and the transitions between them.– to verify the program's logic flow through its various states

• Example Windows Paint program– All the tools, menu items, colors are states– Whenever you select one of these and make the software

change its look, its menus, or its operation, you're changing its state

Page 5: Dynamic Black-Box Testing Part 2 How to reduce the number of test cases using: Decision Tables State Transition.

State Transition Testing

• A state transition model has four basic parts:1. The states that the software may occupy

(shown as circles)2. The transitions from one state to another

(lines with arrows)3. The events that cause a transition (text near

the transitions)4. The actions that result from a transition

Page 6: Dynamic Black-Box Testing Part 2 How to reduce the number of test cases using: Decision Tables State Transition.

Example

• Entering a Personal Identity Number (PIN) to a bank account

Other events: cancel , time-out

Page 7: Dynamic Black-Box Testing Part 2 How to reduce the number of test cases using: Decision Tables State Transition.

State Transition Testing

• Deriving test cases– Test case for every normal situation– Visit each state at least once– Test the state-to-state transitions that look like the

most popular (frequently used)– Test all the error states and returning from the

error states– Test the least common paths between states– Test random state transitions

Page 8: Dynamic Black-Box Testing Part 2 How to reduce the number of test cases using: Decision Tables State Transition.

State Table

• A table showing the resulting transitions for each state combined with each possible event, showing both valid and invalid transitions– List states as rows– List all possible events as columns– Each cell will indicate which state the system will

move to, when the corresponding event occur at some state.

– Negative test conditions will attempt invalid transitions

Page 9: Dynamic Black-Box Testing Part 2 How to reduce the number of test cases using: Decision Tables State Transition.

State TableInvalid PIN Valid PIN Insert card

- - S2 S1) Start State

S3 S6 - S2) Wait for PIN

S4 S6 - S3) 1st try invalid

S5 S6 - S4) 2nd try invalid

S7 - - S5) 3rd Try invalid

? ? - S6) Access to account

- - S1 (for new card) S7) Eat card

State table for PIN example

Page 10: Dynamic Black-Box Testing Part 2 How to reduce the number of test cases using: Decision Tables State Transition.

Airline Reservations System I call Southwest Airlines to make a reservation. I provide information about the origin and destination of my travel, and the date and time that I wish to fly. A reservation is made for me and stored in their system. My reservation is now in the "Made" state.

Depending on the various fare rules, I'm given a certain amount of time to pay for the ticket. It could be within 24 hours; or it might be until 1 hour before departure. Once I pay for the ticket, my reservation changes state. It's now "Paid". On the day of travel, I arrive at the airport in plenty of time, stand in the incredibly long lines, and get a printed copy of my ticket. The reservation is now in the "Ticketed" state. When I give my ticket to the agent and get on the plane, the reservation changes to the "Used" state. Of course, I can cancel my reservation at any time before I get on the plane. If I've paid for it, I should be able to get a refund or at least a credit.

Page 11: Dynamic Black-Box Testing Part 2 How to reduce the number of test cases using: Decision Tables State Transition.

Airline Reservations System

Page 12: Dynamic Black-Box Testing Part 2 How to reduce the number of test cases using: Decision Tables State Transition.

Quiz

• What should state transition diagrams show?• Draw the state transition diagram for the

process of withdrawing from a bank ATM

Page 13: Dynamic Black-Box Testing Part 2 How to reduce the number of test cases using: Decision Tables State Transition.

Decision Tables

• A black box test design technique in which test cases are designed to execute the combinations of inputs and/or stimuli (causes) shown in a decision table

• Provide a systematic way of stating complex business rules

• Can be used by analysts, developers and testers

Page 14: Dynamic Black-Box Testing Part 2 How to reduce the number of test cases using: Decision Tables State Transition.

Decision Table

• Help testers explore the effects of combinations of different inputs and other software states that must correctly implement business rules.

• Testing all combinations may be impractical if not impossible.

• So, test a subset of combinations• But making the choice of which combinations

to test is what makes it effective

Page 15: Dynamic Black-Box Testing Part 2 How to reduce the number of test cases using: Decision Tables State Transition.

Using Decision Tables

1. Identify a suitable function or subsystem which reacts according to a combination of inputs or events (not too many inputs)

2. Identify the aspects that need to be combined, then you put them into a table

3. Identify all of the combinations of True and False – Number of combinations= 2^ number of aspects

4. Identify expected outcome for each combination

Page 16: Dynamic Black-Box Testing Part 2 How to reduce the number of test cases using: Decision Tables State Transition.

Using Decision Tables

5. Finally, write test cases to exercise each of the rules in decision table.

Page 17: Dynamic Black-Box Testing Part 2 How to reduce the number of test cases using: Decision Tables State Transition.

Decision Table Example

• If you are a new customer and you want to open a credit card account then you will get a 15% discount on all your purchases today.

• If you are an existing customer and you hold a loyalty card, you get a 10% discount.

• If you have a coupon, you can get 20% off today (but it can’t be used with the ‘new customer’ discount).

• Discount amounts are added, if applicable.

Page 19: Dynamic Black-Box Testing Part 2 How to reduce the number of test cases using: Decision Tables State Transition.

Decision Table Example

• Note that we have put X for the discount for two of the columns (Rules 1 and 2) – this means that this combination should not occur. You cannot be both a new customer and also holding a loyalty card

• We would have one test for each column or rule of our decision table

• If time-constrained, we may not have time to test all combinations– full table helps us to decide which combinations to test

Page 20: Dynamic Black-Box Testing Part 2 How to reduce the number of test cases using: Decision Tables State Transition.

Quiz

• Scenario: If you hold an “over 60” rail card, you get a 34% discount on whatever ticket you buy. If you are travelling with a child (under 16), you can get a 50% discount on any ticket if you hold a family rail card, otherwise you get a 10% discount. You can only hold one type of rail card.

• Produce a decision table showing all combinations of fare types and resulting discounts and derive test cases from the decision table