当前位置:网站首页>Test plans and test cases

Test plans and test cases

2022-06-11 21:21:00 Are you sorry?

1. The concept and function of test cases

1.1. introduction

For a test engineer , The design and writing of test cases is a necessary ability , However, effective design and skilled writing of test cases is a very complex technology , Test case writers should not only master software testing technology and process , And to the whole software, no matter from the business , Or the design of software 、 Structure of program module 、 Functional specifications, etc. should be thoroughly understood .
The design method of testing does not exist alone , Specific to each test project, there are many methods , Each type has its own characteristics .

1.2. Definition of test cases :

## 1.1.1. What is a test case ?

For a business goal , And a set of test inputs , A case of execution conditions and expected results

1.3. The benefits of writing test cases :

## 1.1.3. The role of test cases :

Design test cases before you start testing , It can avoid blind testing and improve testing efficiency .
The use of test cases highlights the implementation of software testing 、 Have a clear purpose .
After the software version is updated, only a few test cases need to be corrected to start the testing work , Reduce work intensity 、 Shorten the project cycle .
Verify that the software meets customer requirements 、 Reflect the workload of a tester 、 Show the design idea of test case

1.4. Of test cases 4 A feature

Representative : Can represent and cover all kinds of reasonable and unreasonable 、 Legal and illegal 、 Boundary and out of bounds and limit input data 、 Operation etc. .
pertinence : Test the possible errors in the program
Decidability : The correctness of the test execution results is decidable , Each test case should have the corresponding expected results
Reproducibility : For the same test case , The execution results of the system should be the same .

1.5. Test cases usually include the following components :

Use case number 、 Test module 、 Use case title 、 Use case level 、 precondition 、 Test input 、 Perform the operation 、 Expected results , The actual result ….
Test case template

1.6. Test case examples

 Insert picture description here

2. The basic method of writing test cases

2.1. Division of equivalence class
Application scenarios : Mostly used for input boxes

1.1.4. Concept

Equivalence class division refers to the step-by-step division of a large number of classes ( Infinite ) The set of test cases has been reduced very small , But the process is also effective .
Equivalence class : What is equivalent class , A collection of input fields , In this set, each input condition is equivalent .
Generally, it can be divided into effective equivalence class and invalid equivalence class

such as : A teenager's test score ( remarks 13-17 I'm a teenager )
Suppose the age of the teenager is x,13<=x<=17, The math score is y:0<=y<=100
Then age can be divided into x<13,13<=x<=17,x>17, The effective equivalence class is 13<=x<=17, The invalid equivalence class is x<13,x>17
Mathematics scores can be divided into y<0,0<=y<=100,y>100, The effective equivalence class is 0<=y<=100, The invalid equivalence class is y<0,y>100

1.1.5. Example

Calculate two 1~100 The sum of integers between .
If a full test is to be performed , How many test cases should be designed ?
Addition number 1 Yes 1~100 total 100 A value of , Addition number 2 Also have 1~100 total 100 A value of , So the combination between them has 100*100=10000 Two combinations may , But this only tests the value within the normal range . If the data entered by the user is not 1~100 Between , Exhaustive testing is definitely impossible . The idea of equivalence class partition is introduced .

Equivalence classes are divided into :
Effective equivalence class : To conform to 《 Requirements specifications 》, Enter a reasonable set of data
Invalid equivalence class : Means not in conformity with 《 Requirements specifications 》, Input unreasonable data set
As shown in the following figure :
 Insert picture description here
We divide the input field into an effective equivalence class (1~100) And two invalid equivalence classes (<1,>100), And number each equivalent class , Then we can select a representative data from each equivalence class to test , Design the test as shown in the table below
 Insert picture description here

1.1.6: Practice cases

 Insert picture description here

2.2. Boundary value method

The general boundary value analysis is because the data retrieval during program development of the loop body may be due to <,<= mistake .
For example, the following code
  for(int i = 0;i <100; i ++)
{
  int j = i+1;
  System.out.println(" Circle the first “+j+“ Time ”)// Do something in a cycle
}
   The program here is a loop 100 Time , So I can do 100 Time ;
   If the programmer is not careful , hold i <100 It's written in i <= 100, Then add one more loop , In this case, boundary value checking is a good test method .
such as : In a system , Fill in the number of scores a teenager has scored ( Assume that the adult age is x,13<=x<=17, The math score is y:0<=y<=100
According to the above equivalence class division method, we can see , The effective equivalence of age is 13<=x<=17, So the boundary value is 12, 18
Of math scores , The effective equivalence class is 0<=y<=100, So the boundary value is -1,0,100,101

Software testing of data , Is to check the information entered by the user 、 Whether the returned result and the intermediate calculation result are correct . Even the simplest program can handle a huge amount of data , The technique to test these data is , The equivalence classes are divided according to some key principles , To reasonably reduce test cases , These key principles are : The boundary conditions , Sub boundary conditions 、 Null values and invalid data .

1.1.7. The way to determine the boundary value ()

Selection is exactly equal to 、 Just greater than or just less than the boundary value as test data
Master the retrieval of the upper point and the off point in the boundary value

[1 100]
(1,100)
(1,100]

The input requirement is 1 ~ 100 Integer between , So naturally 1 and 100 Two borders , When we design test cases , We should focus on these two boundary problems .
 Insert picture description here
Indicate the : Boundary values are not represented by one of every equivalence class , Instead, test the boundaries of each equivalence class .

2.3. Cause and effect diagram

1.1.8. Concept :

The cause and effect diagram method is more suitable for the situation with more transmission conditions , Test the permutation of all input conditions . The so-called reason is input , The result is the output .

1.1.9. Basic graphical symbols of cause and effect diagram

Identity : If the cause appears , The result appears ; If the cause does not appear , Then the result does not appear .
Not (~): If the cause appears , Then the result does not appear ; If the cause does not appear , The result appears .
or (∨): If one of the several reasons appears , The result appears ; If several reasons do not appear , Then the result does not appear .
And (∧): If there are several reasons , The result is ; If one of the reasons doesn't appear , Then the result does not appear .
 Insert picture description here

1.1.10. Constraint symbol of cause and effect diagram

E( Mutually exclusive ): Indicates that the two reasons will not hold true at the same time , At most one of the two may be true
I( contain ): Indicates that at least one of the three reasons must be true
O( Only ): Indicates that one of the two reasons must be , And there is only one
R( requirement ): Indicates two reasons ,a When it appears ,b There must also be ,a When it appears ,b It's impossible not to appear
M( shielding ): Two results ,a by 1 when ,b Must be 0, When a by 0 when ,b Variable value
 Insert picture description here

1.1.11. Cause and effect diagram test case

for example : There is a processing unit price of 2.5 The vending machine software for boxed drinks . If you put in 2.5 Yuan coins , Press “ coke ”、“ beer ”、 or “ Milk tea ” Button , The corresponding drink will be delivered . If the investment is 3 Yuan coins , Return the drinks as they are delivered 5 Dimes .

Analysis of this paragraph shows that , We can list the reasons and results
reason ( Input ):
input 2.5 Yuan coins ;
input 3 element ;
Press “ coke ” Button ;
Press “ beer ” Button ;
Press “ Milk tea ” Button .
In the middle : ① The coin has been put in ;② Button has been pressed
result ( Output ):
return 5 Dimes ;
Send out “ coke ” drinks ;
Send out “ beer ” drinks ;
Send out “ Milk tea ” drinks ;
 Insert picture description here

Decision table method

 Insert picture description here

2.4. Scene method

1.1.12. The idea of test case design
Today's software almost uses event triggering to control the process , When the event is triggered, the scene is formed , Different triggering sequence and processing results of the same event form event flow . This idea of software design can also be introduced into software testing , It can vividly describe the situation when the event is triggered , It is helpful for the test designer to design test cases , At the same time, it makes the test cases easier to understand and execute .
A use case scenario is a process determined by describing the path through the use case ,
This flow through process traverses all basic and alternative flows from the beginning to the end of the use case .
 Insert picture description here
Follow each possible path through the use case in the figure above , Different use case scenarios can be identified . Start with the basic flow , Then combine the basic flow with the alternative flow , You can identify the following use case scenarios :
 Insert picture description here
The difference between basic flow and alternative flow
 Insert picture description here

1.1.13. Bank case ATM:

Personal identification number (PIN=personal identification number ), A secret identification code used to protect a smart card from misuse .PIN Similar to password , Only the card owner knows what to do PIN. Only those who own the smart card and know PIN People can use the smart card
 Insert picture description here
In the first test , According to the test plan , We need to verify that the withdrawal use case has been implemented correctly . The entire use case has not been implemented at this time , Only the following event flow is implemented :
Basic flow - Withdraw the default amount (100 element 、200 element 、500 element 、1000 element )
Alternative streams 2 - ATM There is no cash
Alternative streams 3 - ATM There's not enough cash in
Alternative streams 4 - PIN Mistake
Alternative streams 5 - Account does not exist / Wrong account type
Alternative streams 6 - The book amount is insufficient
 Insert picture description here
For this 7 Each scenario in each scenario needs to identify test cases . You can use matrices or decision tables to identify and manage test cases .
Start by identifying the data elements needed to execute the use case scenario . then , For each scene , At a minimum, identify test cases that contain the appropriate conditions for executing the scenario .
A common format is shown below , Each line represents a test case , The columns represent the test case information .
In this example , For each test case , There is a test case ID、 Conditions ( Or explain )、 All the data elements involved in the test case ( As input or already in the database ) And the expected results .
 Insert picture description here

2.5. Wrong guess

   Wrong guess : Infer various errors that may exist in the program according to experience or intuition , So as to write a black box test method to check these wrong test cases 

for example , Test the call function of mobile terminal , Various call failures can be designed to supplement the test example :

  1. nothing SIM Exhale when the card is inserted ( Non emergency call )
  2. Insert overdue SIM Card for exhalation
  3. If the RF device is damaged or no signal area is inserted, it is effective SIM Card exhaled
  4. Normal network , Insertion works SIM card , Invalid number ( Such as 1、888、333333、 Don't enter any number, etc )
  5. Normal network , Insertion works SIM card , Use “ Speed dial ” The number of invalid number set by function call out

skill : The most important thing is to think about and analyze all aspects of the test object , Refer to what you found before bug Relevant data , Lessons learned , Individuals think more about abnormal situations 、 On the other hand 、 Special input , Treat the program as an attacker , Can design a more perfect test case to .

2.6. Orthogonal table method

 Orthogonal table can sample evenly within the range of factors , So that each test has a strong representativeness , Because the orthogonal table has the characteristics of balanced dispersion , Some requirements of comprehensive experiment are ensured , These experiments often can better or better achieve the purpose of the experiment . The design of orthogonal experiment includes two parts : First of all , How to arrange the experiment ; second , How to analyze the experimental results .

Application scenarios : There are multiple controls in an interface , Each control has multiple values , Controls can be combined with each other , impossible ( There's no need ) Write a use case for each combination , How to test with the least optimal combination .—— Orthogonal array method

Decision table , Cause and effect diagrams also consider control combinations , But the number of combinations is small ( Usually not more than 20 in )
The formula :
 Insert picture description here
 Insert picture description here
What are the characteristics of orthogonal table test case design method ?
1、 Cover the most operations with the least number of experiments , There are few test case designs , Efficient , But it's complicated ;
2、 For basic verification functions , And the defects caused by secondary integration , You can usually find out ; But deeper flaws , More complex defects , There's nothing I can do about it

原网站

版权声明
本文为[Are you sorry?]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/03/202203011702363344.html