With 3 years of testing experience, you don’t know how to use test cases, right?

The state migration method mainly focuses on testing the correctness of state transfer. For a finite state machine, test to verify whether it can produce the required state changes within given conditions, whether there are unreachable states and illegal states, whether it is possible to produce illegal state transitions, etc. Test transitions between states by constructing events that cause state transitions.

1. Application scope

The idea of ​​the state transition method is to provide an idea to string together multiple state transitions for testing. This method is suitable for situations where there are many functional states and the transitions of various states need to be tested, and the testing of these state transitions is easily missed in actual work. Such as players, remote control buttons, etc.

2. Steps of state migration method

  1. Analyze requirements and organize all status;

  2. Draw a state transition diagram;

  3. List status-event table;

  4. Get the state transition tree (test path);

  5. Get test cases based on state transition tree

3. Case:

Demand: Through a certain ticket purchasing system, customers can purchase train tickets in advance to go to a certain place.

  1. The user logs in to the ticket purchase system, selects the departure place, destination, and departure date, selects a train and clicks "Book", fills in the ticket booker's information, and clicks to submit the order; the current order status is "Unpaid";

    The user manually cancels the order and the ticket status is updated to "Cancelled";

    If payment is not made within 45 minutes, the order will be automatically canceled and the ticket status will be "cancelled";

  2. The user pays the ticket and the ticket status changes to "paid";

  3. The user arrives at the station to pick up the ticket through the automatic ticket machine or ticket window, and the ticket status is "ticketed";

  4. You can change your ticket half an hour before driving. If the change is successful, the ticket status will be "Change successful";

  5. After checking the ticket that has been issued/changed and boarding the train, the ticket status will change to "used";

  6. You can refund the ticket half an hour before driving. If the refund is successful, the ticket status will be "Refund Successful".

a. Organize all status of ticket orders:

Unpaid, canceled, paid, ticket issued, refund successful, change successful, used

b. Draw a state transition diagram:

picture

c. List the status-event table:

This item is not necessary, you can skip this step according to the actual situation and get the state transition tree directly;

picture

d. Get the state transition tree (test path):

picture

Get the test path through the above:

  1. Unpaid --> Canceled

  2. Unpaid --> Paid --> Ticket issued --> Change successfully --> Refund successful

  3. Unpaid --> Paid --> Ticket issued --> Change successfully --> Used

  4. Unpaid --> Paid --> Ticket issued --> Refund successful

  5. Unpaid --> Paid --> Invoiced --> Used

  6. Unpaid --> Paid --> Change successfully --> Refund successful

  7. Unpaid --> Paid --> Change successfully --> Used

  8. Unpaid --> Paid --> Refund successful

  9. Unpaid --> Paid --> Used

e. Obtain test cases based on the state transition tree

Each of the above test paths is a test case, and each path can be covered and tested. For state transitions, there are multiple event triggers and operations that cover multiple events. For example, the test path "Unpaid --> Canceled" needs to test 2 situations: 1) The user manually cancels the ticket order 2) More than 45 minutes If the user fails to pay, the ticket order will be automatically canceled.

4. Summary

In actual work, for products with complex business processes, when use case design cannot be carried out well through the scenario coverage method, the idea of ​​​​the state migration method can be applied, starting from various states of the business, and through the switching conditions between these states Test coverage is performed in series to ensure high coverage of use cases.

Finally: The following is the supporting learning materials. For those who are doing [software testing], it should be the most comprehensive and complete preparation warehouse. This warehouse has also accompanied me through the most difficult journey. I hope it can also help you!

Software testing interview applet

A software test question bank that has been used by millions of people! ! ! Who is who knows! ! ! The most comprehensive interview test mini program on the Internet, you can use your mobile phone to answer questions, take the subway, bus, and roll it up!

Covers the following interview question sections:

1. Basic theory of software testing, 2. web, app, interface function testing, 3. network, 4. database, 5. linux

6. Web, app, interface automation, 7. Performance testing, 8. Programming basics, 9. HR interview questions, 10. Open test questions, 11. Security testing, 12. Computer basics

  How to obtain the full set of information: Click on the small card below to get it yourself

Guess you like

Origin blog.csdn.net/weixin_57794111/article/details/132851795