Software test case design method (2)

Orthogonal testing method for test case design

1. Definition of orthogonal test method

Orthogonal experiment method: A method of using an already created orthogonal table to arrange experiments and analyze data. This method is simple and easy to implement, the calculation is tabular, and it has good applicability.

2. Orthogonal Experimental Method Design Steps

  • Extract all factors in the function description and clarify the factor status

Factor: Each element that can affect the experimental results is called a factor, and the value of this element is called the state of the factor.

  • Weighted screening of factors to generate factor analysis tables
  • Use orthogonal tables to construct test data sets

3. Example demonstration

Example of web site configuration
Assume there is a WEB site, which has a large number of servers and operating systems, and is browsed by many browsers with various plug-ins:
Web browser: netscape6.2, IE6.0, opera4.0
plug-in: None, RealPlayer, MediaPlayer
Application server: IIS, Apache, Netscape Enterprise
Operating system: Windows 2000, Windows NT, Linux
Analysis:
Factor 1: web browser
Factor status: ① netscape6.2 ② IE6.0 ③ opera4.0
Factor 2: plug-in
Factor status: ① None ②RealPlayer③MediaPlayer
Factor 3: Application server
Factor status: ①IIS②Apache③Netscape Enterprise
Factor 4: Operating system
Factor status: ①Windows 2000②Windows NT③Linux
or above 4 factor 3 status, L9 orthogonal table must be applied, strength S=2

Use case number web browser plug-in application server operating system
1 ①netscape6.2 ①None ①IIS ①Windows 2000
2 ①netscape6.2 ②RealPlayer ②Apache ②Windows NT
3 ①netscape6.2 ③MediaPlayer ③Netscape Enterprise ③Linux
4 ②IE6.0 ①None ②Apache ③Linux
5 ②IE6.0 ②RealPlayer ③Netscape Enterprise ①Windows 2000
6 ②IE6.0 ③MediaPlayer ①IIS ②Windows NT
7 ③opera4.0 ①None ③Netscape Enterprise
8 ③opera4.0 ②RealPlayer ①IIS ③Linux
9 ③opera4.0 ③MediaPlayer ②Apache ①Windows 2000

Note: Because the orthogonal table can be found online, then just substitute the factors and factor states in the example. If it is a mixed orthogonal table that cannot be found online, you can write it yourself.

4. Advantages and disadvantages of orthogonal test method

  1. The number of generated test cases is limited and controllable, saving testing man-hours (as in the above example, if the general test method is used, 3 to the fourth power, which is 81 test cases, will be generated to achieve full coverage, while using orthogonal test cases Experimental method, only 9 test cases were generated, which is representative)
  2. Test cases have certain coverage.
    Disadvantages: The practicality is limited. The multi-factor and multi-state that appear in actual tests are likely to use various hybrid orthogonal tables, and we may not be able to find these orthogonal tables to apply (if you can write them, you can do it yourself Write)

Note: How to write an orthogonal table will be summarized in another chapter.

Functional diagram method for test case design

1. Definition of function diagram method

Function diagrams are suitable for test targets with multiple states, and each state has complex transition relationships.
The functional diagram model consists of a state transition diagram (a diagram describing state transitions) and a logical functional model (a diagram describing the logic of state transitions).
Rules: Three rules of sequence, selection, and repetition are defined.

2. Methods to generate test cases from functional diagrams

(1) Generate local test cases: In each state, local test cases are generated from the cause-and-effect diagram, and the local test cases are composed of input data combinations and output data.
(2) Generate test path: Use the above three rules to generate a test path from the initial state to the final state.
(3) Generate test cases: Use conditional construction trees to synthesize test paths and local test cases to form the final use case from the initial state to the final state and the input data combination and output data combination of each state.

3. Steps of state migration diagram

(1) Draw the state transition diagram
(2) List the state-event table
(3) Obtain the state transition tree
(4) Develop the test path
(5) Write test cases according to the test path

4. Example of MP3 playback function

The MP3 playback function in the mobile phone is described as follows: you cannot press any keys when there is no MP3 track selected; you cannot press the R key at the starting point of MP3 playback; you cannot press the P key and F key at the end point of MP3 playback; MP3 can only be played in the paused state. recording. Please use functional diagramming method to design test cases.
The R key rewinds, the P key plays, the F key fast forwards, the RC key records, and the idle key pauses.
Insert image description here

  1. Create a state transition diagram, as shown in the figure
  2. Create a status event table, as shown in the figure
    Insert image description here
  3. Create a state transition tree
    Insert image description here
  4. Each path corresponds to a test case, and the test cases are written according to the status tree.
Use case number test title importance level Preconditions Steps expected output
MOBILE_ST_MP3_PLAY_001 In the paused state, record first and then pause. high MP3 track selected and paused 1. Press the RC key
2. Press the idle key
Record normally first and then pause
MOBILE_ST_MP3_PLAY_002 In paused state, play first and then fast forward high The MP3 track is selected and is not at the end of the paused state 1. Press the P key
2. Press the F key
Play the track first and then fast forward
MOBILE_ST_MP3_PLAY_003 In paused state, play first and then rewind high The MP3 track is selected and is not at the end of the paused state 1. Press the P key
2. Press the R key
The track plays first and then goes backwards
MOBILE_ST_MP3_PLAY_004 In the paused state, play first and then pause. high The MP3 track is selected and is not at the end of the paused state 1. Press the P key
2. Press the idle key
The track plays first and then pauses
MOBILE_ST_MP3_PLAY_005 In paused state, fast forward first and then play high The MP3 track is selected and is not at the end of the paused state 1. Press the F key
2. Press the P key
Fast forward the track first and then play it
MOBILE_ST_MP3_PLAY_006 In the paused state, first fast forward and then rewind high The MP3 track is selected and is not at the end of the paused state 1. Press F key
2. Press R key
Fast forward and then rewind the track
MOBILE_ST_MP3_PLAY_007 In the paused state, fast forward first and then pause. high The MP3 track is selected and is not at the end of the paused state 1. Press the F key
2. Press the idle key
Fast forward the track first and then pause it
MOBILE_ST_MP3_PLAY_008 In the paused state, first rewind and then fast forward high The MP3 track is selected and is not at the starting point in the paused state 1. Press R key
2. Press F key
The track rewinds first and then fast forwards
MOBILE_ST_MP3_PLAY_009 In paused state, rewind first and then play high The MP3 track is selected and is not at the starting point in the paused state 1. Press R key
2. Press P key
Rewind the track first and then play it
MOBILE_ST_MP3_PLAY_010 In the paused state, first reverse and then pause. high The MP3 track is selected and is not at the starting point in the paused state 1. Press R key
2. Press idle key
The track rewinds first and then pauses

Scenario method of test case design

1. Definition of scenario method

The scenario method describes the program's functions and business processes through scenarios. Traverse the entire scene by traversing all basic and alternative streams.
Scenario = basic flow + alternative flow
Scene: It consists of a series of related activities, and the activities in the scene can also be composed of a series of related scenes.
Basic flow: The simplest path through the use case without any errors. The program is executed directly from start to end.
Alternative flow: starting from the basic flow or alternative flow, occurring under specific circumstances, moving to other possibilities in the middle, and then returning to the basic flow (alternative flow 1 and alternative flow 3 in the figure below), or directly End the use case. (As shown in the figure below, alternative flow 4)

2. Generate use cases from basic flow and alternative flow diagrams

as the picture shows:
Insert image description here

scene 1 Basic flow → end use case
Scene 2 Basic flow→Alternative flow 1→End use case
Scene 3 Basic flow→Alternative flow 1→Alternative flow 2→End use case
Scene 4 Basic flow→Alternative flow 3→End use case
Scene 5 Basic flow→Alternative flow 3→Alternative flow 1→End use case
Scene 6 Basic flow→Alternative flow 3→Alternative flow 1→Alternative flow 2→End use case
Scene 7 Basic flow→Alternative flow 3→Alternative flow 4→End use case
Scene 8 Basic flow→Alternative flow 4→End use case

3. Scenario design steps

  • Draw basic flow and alternative flow diagrams according to requirements
  • Write out all scenarios based on basic flow and alternative flow diagrams
  • Write use cases based on scenarios
  • Review the use cases, remove redundant items, and fill in the use cases with test data

4. Example of online shopping system

Example: A user enters an online shopping website to shop, selects products and then makes a purchase. At this time, he needs to log in with an account. After successful login, he pays online, generates an order, and completes the entire shopping process. Please use scenario method to design test cases.

elementary stream Purchase goods, log in successfully, pay online, and generate an order
Alternative stream 1 Account does not exist
Alternative stream 2 Account password is wrong
Alternative stream 3 Insufficient balance
Alternative stream 4 The account balance is 0
Generate scenarios from basic and alternative flows
Scenario 1—Successful Shopping elementary stream
Scenario 2—The account does not exist Basic flow→Alternative flow 1
Scenario 3—Incorrect account and password Basic flow→Alternative flow 2
Scenario 4—Insufficient account balance Basic flow→Alternative flow 3
Scenario 5—The account amount is 0 Basic flow→Alternative flow 4

Design use case == (V: valid; I: invalid; n/a: not suitable for this use case) ==

Use case ID Scenes account password balance expected outcome
1 Scenario 1—Successful Shopping V V V successful shopping
2 Scenario 2—The account does not exist I n/a n/a Prompt account does not exist
3 Scenario 3—Incorrect account and password (correct account, incorrect password) V I n/a It prompts that the account or password is incorrect, please log in again.
4 Scenario 3—Incorrect account and password (wrong account, correct password) I V n/a It prompts that the account or password is incorrect, please log in again.
5 Scenario 4—Insufficient account balance V V I Insufficient balance, please recharge
6 Scenario 5—The account amount is 0 V V I Insufficient balance, please recharge

Review the use cases, remove redundancy, and fill in test data (scenario 4 and scenario 5 are merged)

Use case ID Scenes account password balance expected outcome
1 Scenario 1—Successful Shopping Amy 123456 2000 successful shopping
2 Scenario 2—The account does not exist Jone n/a n/a Prompt account does not exist
3 Scenario 3—Incorrect account and password (correct account, incorrect password) Amy 111111 n/a It prompts that the account or password is incorrect, please log in again.
4 Scenario 3—Incorrect account and password (wrong account, correct password) Amys 123456 n/a It prompts that the account or password is incorrect, please log in again.
5 Scenario 4—Insufficient account balance Amy 123456 0 Insufficient balance, please recharge

5. Applicable Scenarios of Scenario Method

The scenario method is suitable for solving systems or functions with clear business processes.

Guess you like

Origin blog.csdn.net/u011090984/article/details/91388145