Design method of test case (2)

1. There is a file management system that requires users to enter the date expressed in year and month. Assume that the date is limited to January 1990 to December 2049, and it is specified that the date consists of 6 digits, the first 4 digits represent the year, and the last 2 digits represent the month. The current equivalence class division method is used to design test cases to test the "date checking function" of the program.

 

  1) Divide the equivalence classes and number them, and the results of the equivalence class division in the table below

 

image

 

2) Design test cases to cover all effective equivalence classes. There are 3 effective equivalence classes listed in the table, numbered respectively ①, ⑤, ⑧. The designed test cases are as follows: the     expected result coverage of the test data is effective, etc. Price category 200211 input valid ①, ⑤, ⑧   3) Design a test case for each invalid equivalence class. The design results are as follows:     Test data Expected result Covered invalid equivalence class 95June invalid input ② 20036 invalid input ③ 2001006 invalid input ④

   198912 invalid input ⑥
    200401 invalid input ⑦
    200100 invalid input ⑨
    200113 invalid input ⑩
    
3. The NextDate function contains three variables: month, day and year. The output of the function is the date one day after the input date. For example, if the input is March 7, 2006, the output of the function is March 8, 2006. The input variables month, day and year are required to be integer values ​​and meet the following conditions:

 

  ①1≤month≤12
  ②1≤day≤31
  ③1920≤year≤2050  

 

  1) The effective equivalence class is:

 

    M1={month:
    1≤month≤12} D1={date: 1≤date≤31}
    Y1={year: 1812≤year≤2012}

 

  2) Young conditions

 

If any one of the conditions in ① ~ ③ fails, the NextDate function will produce an output indicating that the corresponding variable exceeds the value range, such as "The value of month is not in the range of 1-12". Obviously, there are still a large number of invalid combinations of year, month, and day. The NextDate function will output these groups together: "Invalid input date". Its invalid equivalence class is:

 

    M2={month:month<1}
    M3={month:month>12}
    D2={date:date<1}
    D3={date:date>31}
    Y2={year:year<1812}
    Y3={year: Year>2012}

 

  Weak general equivalence test cases

 

  Month Date Year Expected output
   6 15 1912 June 16, 1912
  Strong general equivalence test cases are the same as weak general equivalence test cases.
  Note: Weak--single defect hypothesis; Robust--Invalid value is considered 
  
  (1) Weak Robust equivalence class test

 

  Use case ID Month Date Year Expected output
  WR1 6 15 1912 June 16,
  1912 WR2 -1 15 1912 Month not in 1~12
  WR3 13 15 1912 Month not in 1~12
  WR4 6 -1 1912 Date not in 1~31
  WR5 6 32 1912 Date is not in 1~31
  WR6 6 15 1811 Year is not in 1812~2012
  WR7 6 15 2013 Year is not in 1812~2012

 

  (2) Strong and robust equivalence test

 

  Use case ID Month Date Year Expected output SR1 -1 15 1912 Month is not in 1~12 SR2 6 -1 1912 Date is not in 1~31

 

 SR3 6 15 1811 The year is not in 1812~2012 SR4 -1 -1 1912 Two invalid and one valid SR5 6 -1 1811 Two invalid and one valid SR6 -1 15 1811 Two invalid and one valid SR7 -1 -1 1811 Three invalid   4. Commission problem equivalence test cases, which define equivalence classes based on the output range of the commission function to improve the set of test cases.

 

Output sales ≤ 1,000 yuan, commission 10% 1000 <sales ≤ 1800 commission = 100 + (sales-1000) * 15% sales> 1800 commission = 220 + (sales-1800) * 20% test case 45) Stock (30) Barrel (25) Sales commission 1 5 5 5 500 50 2 15 15 15 1500 175 3 25 25 25 2500 360

 

The input value is selected according to the output domain, so that it falls within the equivalence class of the output domain, which can be combined with weak and robust test cases.

 

 

Boundary value analysis method:

 

1. Method introduction

 

1. Definition:

 

The boundary value analysis method is a black box test method to test the boundary value of input or output. Usually the boundary value analysis method is used as a supplement to the equivalence class division method. In this case, the test cases come from the equivalence class boundary. 

2. The difference with the equivalence division

  1) Boundary value analysis is not to randomly pick one from a certain equivalence class as a representative, but to make every boundary of this equivalence class as a test condition.

  2) The boundary value analysis considers not only the input conditions, but also the test conditions generated by the output space.

3. Consideration of boundary value analysis method:

  Long-term testing work experience tells us that a large number of errors occur on the boundary of the input or output range, rather than inside the input and output range. Therefore, by designing test cases for various boundary conditions, more errors can be detected. To design test cases using boundary value analysis methods, first determine the boundary conditions. Usually the boundary of the input and output equivalence classes is the boundary case that should be tested. The value that is exactly equal to, just greater than or just less than the boundary should be selected as the test data, rather than the typical value or any value in the equivalence class as the test data.

4. Common boundary values

  1) For 16-bit integers, 32767 and -32768 are boundaries 2) The cursor on the screen is at the upper left and lower right positions 3) The first and last rows of the report 4) The first and last of the array elements 5) The 0th, 1st, 2nd and last time of the loop

5. Boundary value analysis

 

  1) The boundary value analysis uses the same division as the equivalence class division method, except that the boundary value analysis assumes that more errors exist on the boundary of the division, so test cases are designed on the boundary of the equivalence class and on both sides. Example: Test the function to calculate the square root --Input: real number --Output: real number

 

       --Specification: When inputting a number that is 0 or greater than 0, return its positive square root; when inputting a number less than 0, display the error message "Illegal square root-input value is less than 0" and return 0; library function Print-Line can be used to output error messages.
        


  2) Equivalence class division:

    I. The following division can be considered:

      a, input (i)<0 and (ii)>=0 b, output (a)>=0 and (b) Error

    II. There are two test cases:

      a. Input 4 and output 2. Corresponds to (ii) and (a). b. Input -10, output 0 and error message. Corresponds to (i) and (b).

  3) Boundary value analysis:

    The boundary of division (ii) is 0 and the largest positive real number; the boundary of division (i) is the smallest negative real number and 0. From this, the following test cases are obtained: a, input {minimum negative real number} b, input {negative number with very small absolute value} c, input 0 d, input {positive number with very small absolute value} e, input {maximum positive real number} 4) Under normal circumstances, there are several types of boundary checks included in software testing: numbers, characters, positions, weights, sizes, speeds, orientations, dimensions, spaces, etc.

  5) Correspondingly, the boundary values ​​of the above types should be in: maximum/minimum, first/last, up/down, fastest/slowest, highest/lowest, shortest/longest, empty/full, etc.

  6) Use boundary values ​​as test data

 

 

image

Software testing exchange group: 785128166

WeChat public account: Programmer Erhei; After paying attention, you can receive a set of video resources for free; explain in detail: python automated testing, web automation, interface automation, mobile terminal automation, interview experience and other related content, the value of learning resources depends on you Action, don’t be a "collector"

Here is a collection of selected dry goods articles for functional testing:

Dry goods sharing | Featured article collection of functional tests (Are you afraid that you can't find the article you need?)

Guess you like

Origin blog.csdn.net/m0_52668874/article/details/115219565