Soft test (3) basic introduction to test cases

Preface

This chapter mainly describes the concept of test cases and the introduction of basic usage
ps: I am really dizzy now. Although it is so late, I must summarize what I have learned today before going to bed



1. Concept

Test Case (Test Case) : It is a set of test inputs, execution conditions and expected results designed for a specific purpose, so as to test whether a specific requirement is met. A large number of test cases are used to verify the operation effect of the software, which is the basis for guiding the test work.

  • Simply put, test whether the expected result is equal to the actual result, if yes, then pass, otherwise there is a bug
  • The main problem that the test case solves is what to test? How to measure?

Example: Buy a mobile phone and press the power button (equivalent to input a set of data to test). The execution condition refers to the prerequisites for starting up, such as whether there is electricity; the expected result is that the mobile phone can be turned on smoothly, then after the test is completed, whether it reaches The desired demand (smooth boot)


Two, test case method

1. Equivalence class division method

1) Concept

  • It is an important and commonly used black-box testing method. It does not need to consider the internal structure of the program, only the input specifications of the program. It reasonably categorizes the test processes that cannot be exhaustive, so as to ensure that the designed test cases are complete and representative.

For example: calculator test, due to the low test efficiency one by one, you cannot add every number again, so you must classify the test. Divide the input number into:
1. Integer (integer in the range -99 to 99) Take the largest, smallest, middle
2, decimal (integer within the range -99 to 99)
3. Symbol (±/ ,.,!@#¥%……& ())
5. Chinese characters
6, space
7, no input

2) Equivalence class division

  • Effective Equivalence Class: Refers to a reasonable data set that meets the Requirements Specification
  • Invalid equivalence class: Refers to a data set that does not comply with the "Requirements Specification" and is input unreasonably

3) Equivalence class thinking steps

  • 1. First determine the effective and invalid equivalent classes
  • 2. The effective equivalence class is the title condition (the extreme value (boundary value) at both ends must be judged, and any value in the middle must also be judged)
  • 3. Invalid equivalence class first classify the conditions contrary to the conditions, and then find the special cases (Chinese, English, symbols, spaces, empty)

4) Example display

Example: Calculate the sum of integers from 1 to 100 (including 1 and 100)

  • Analysis: First list valid and invalid equivalent conditions according to the meaning of the question.
    Valid equivalent conditions: [1,100] integer (usually the critical value and any value in between)
    invalid equivalent conditions:
    1) <1 or >100
    2) Decimals
    3) Chinese and English letters
    4) Special symbols (¥%&…)
    5) Space, and empty

The list display is
Insert picture description here
generally one box with the correct value, one box with the wrong value, and no two boxes have the wrong value, because it is easier to determine which box has the wrong value.

5) Summary

  • When we are testing the text box program, we can consider the following situations:

1. Consider input length
2. Consider input type
3. Composition rules
4. Whether it is empty
5. Whether it is case sensitive
6. Whether repeating
7. Whether removing spaces

2. Boundary value analysis method

1) Concept

  • Boundary refers to some specific situations that are slightly higher than the boundary value and slightly lower than the boundary value of the input equivalence class and the output equivalence class. The boundary value analysis method is also a commonly used black box test method (it is complementary to the equivalence class analysis method)

For example: the programmer will input a statement that the parameter value must be greater than 0 and an integer less than 100, and the boundary conditions are set incorrectly: write> as >= and <as <=.

Among them, the demarcation point between valid data and invalid data is often used as a judgment point for programmers to write programs. It is a place where programmers are prone to make mistakes, so it is also the test content of testers.

2) How to solve such problems

  • Specific test case writing ideas: find the boundary value and the values ​​at both ends of it, and test separately;

For example (the calculator tests the integers between 0 and 100): In general, you need to test the boundary value (0 and 100) and the numbers on both sides of the boundary value (-1 and 1 and 101 and 99) respectively

3) Note: The value of the boundary value varies according to the input range interval , but it is necessary to take the upper point value, the out point value and the inner point value. ( Close both sides, open the middle )
Insert picture description here

4) Example display

Exercise: Modify mobile banking login password: The password must be a combination of letters and numbers, and the length of the password is between 8 and 24 (including 8 and 24)

  • Analysis: 8 boundaries 7, 9; 24 boundaries 23, 25;

Insert picture description here

5) The difference between boundary value and equivalence class: boundary value analysis is not to pick one from a certain equivalence class as a representative, but each boundary of this equivalence class as a test condition

3. Cause and effect diagram (just understand)

1) Concept

Cause: input condition.
Result: output condition, output result.
Applicable to situations where there are mutual constraints and mutual dependence between input conditions;

2) Features

Consider the mutual restriction and combination
of input conditions. Consider the dependence of output conditions on input conditions.

3) Symbols in the cause and effect diagram
Insert picture description here
1. Identity (-): There is a cause and there is an effect, and there is no effect without a cause.
2. No (~): There is no cause and no effect, and there is no cause and effect.
3, or (^): Condition One is true, the result is true, the conditions are all false, the result is false
4. And (V): the conditions are all true, the result is true, one condition is false, the result is false

4. Decision table

1) Components:

  • 1. Condition pile: all conditions
  • 2. Action pile: all results
  • 3. Condition item: value for condition pile
  • 4. Action item: value for action stake

2) Writing steps:

  • 1. List all the conditions and action stakes
    2. Fill in the items in the conditions and action stakes
    3. Simplify the judgment form

Note: If "-" appears, it means this option does not affect the final result.

3) Example display

Exercise: The software system requirements for the automatic recharge of the transportation card are as follows:

The system only accepts 50 or 100 yuan banknotes, only one banknote can be used at a time, and the recharge amount can only be 50 yuan or 100 yuan at a time.
If you enter 50 yuan banknotes and choose to recharge 50 yuan, the card
will be returned after the recharge, and the recharge is successful; if you enter 50 yuan banknotes and choose to recharge 100 yuan, you will be prompted that the input amount is insufficient, and 50 yuan will be returned;
if you enter 100 yuan banknotes, and Choose to recharge 50 yuan and return the card after completing the recharge. It will prompt that the recharge is successful, and the change is 50 yuan;
if you enter a 100 yuan bill and choose to recharge 100 yuan, the card will be
refunded after the recharge is completed, and the recharge is successful; if you do not select within the specified time after entering the bill The recharge button returns the entered banknotes and prompts an error;
if the recharge button is selected and the banknotes are not entered, an error is displayed
Insert picture description here

  • Analysis:
    1. Find all input condition numbers
    2. Find all output condition numbers
    3. Find all input and output constraints

  • Input:
    1. Input 50 yuan
    2. Input 100 yuan
    3. Choose to recharge 50 yuan
    4. Choose to recharge 100 yuan

  • Output:
    1. Complete the recharge, return the card
    2. Prompt that the recharge is successful
    3. Change change
    4. Prompt an error

  • Analyze the restriction relationship of input and output, and the table is as follows: 1 represents operation
    Insert picture description here

5. Scene method
  • Mainly used to test business processes;
  • Divided into basic flow (correct flow) and alternative flow (wrong flow)
    Basic flow: an operation path implemented in accordance with the correct business process (simulating the correct operation flow)
    Alternate flow: the operation flow that leads to errors in the program (simulation) Wrong operation process)

In the smoke test, the scenario method is mainly used to test;

6. Process analysis method

It is suitable for sequential testing (usually used in business processes and installation processes);
each process is a test case, which is only testing whether the overall process is correct, and the details need to be improved using equivalence classes, boundary values ​​and other methods;

7. Wrong speculation
  • Design test cases based on intuition and experience, which are summarized based on the related bug data of previous projects;
8. Orthogonal arrangement method
  • It is an efficient, fast and economical method to select representative points from a comprehensive test ( evenly dispersed, neat and comparable ). When the number of combinations is too large, it is impossible to create test cases for every combination. How to use the smallest set of test cases to obtain the largest test coverage -using the orthogonal arrangement method

1) The concept of orthogonal table

  • A special table, the general orthogonal table is written as: Ln (m^k)

n is the number of rows in the table, that is, the number of times the combination needs to be tested.
K is the number of columns in the table, indicating the number of controls (the number of factors, or the number of factors)
m is the number of values ​​contained in each control (each The level of the factor, that is, the number of states of each factor)
such as: L9 (3^4): called 4 factors 3 levels , which means there are 4 controls, each control has 3 values, 9 is the number of combinations that need to be tested

2) Example display

Case: Character attribute setting program: There are multiple controls (font, character style, color, font size) in the form, and each control has multiple values.
Font: Song-like, Kaiti, Huawen Caiyun
Character style: bold, italic, underline
Color: red, green, blue
Font size: 20th, 30th, 40th

  • analysis:

Step 1: According to the number of controls in the tested program and the number of values ​​for each control, select a suitable orthogonal arrangement of 4 controls (factors) font, character style, color, font size, each control has 3 A value (horizontal), so choose L9 (3^4) orthogonal row list.

Step 2: List the controls and their values, and number the values.
Insert picture description here
Step 3: Map the controls and their values ​​to the orthogonal array table
1. Map the A, B, C, and D in the orthogonal array table (Factors) were replaced with 4 controls
Insert picture description here
Insert picture description here

3) Hybrid orthogonal table

  • The number of levels is different: the number of levels (value of the variable) of the factor (variable) is not the same

Example: If you
Body Type Age Group Gender Fat Old Man Moderate Male Youth Thin Female Child
can’t find an existing orthogonal table, you can only use the orthogonal table generation tool allpairs to generate

  • Steps for usage:

1. Make a value table (just list the data, no serial number)
2. Copy the data of the value table and save it in a text file (be careful not to change any format, for example, the file is called Test2.txt)
3. Put the text The document is placed in the allpairs folder
4. After win+r, enter cmd to enter the console
5. Use the console code to enter the allpairs folder
6. Enter allpairs.exe Test2.txt>success.txt in the console (success is my own The name, used to store the generated combination use case, can be automatically generated, without having to build it in advance)



Three, the choice of test method

  • Usually when determining the test method, there are the following reference principles (1/2):

1. If testing functions and processes, use scenario method

2. Where data needs to be input, we must use the equivalence class division method, and pay attention to the boundary value method for detailed testing

3. If there is a conditional combination, we have to use the cause and effect diagram to make a judgment table

4. For configuration software, if there are many combinations, we need to use orthogonal tables to scientifically select test cases

5. If the coverage standard is not reached, add some test cases

6. Add some test cases based on experience (error inference method)

Guess you like

Origin blog.csdn.net/Makasa/article/details/104528355