"Software Testing" Boundary value analysis method

Source: Internet
Author: User

The book has used cliffs to describe software boundaries: if you can walk confidently and safely on the edge of a cliff without falling down, the flat will almost never be a cinch. Boundary conditions are special cases, because programming is fundamentally about creating problems on the boundary. The practice shows that faults often appear on the boundary of domain or range of definition.

1. The concept of the boundary value analysis method

The boundary value analysis method is a black box test method for testing the boundary value of the input, and the boundary value analysis method is usually used as a supplement to the equivalence class partitioning method, in which case the test case comes from the boundary of the equivalence class.

#include <cstring> #include <cstdio> #include <iostream> #include <cstdlib> #include <cmath >using namespace Std;int a[10];int main () {    memset (A,-1, sizeof (a));    for (int i = 1; I <=; i + +)        a[i] = i;    return 0;}

 The above code is a very common array of cross-border problems, the scope of the array is 0~9, and the above assignment is in the 1~10 scope of operation, so in the above code implementation A[0]=-1, not the a[0]=0 we initially wanted. This is not the result we want to get.

2. Selection of test case principles by boundary value analysis

1) If the input condition specifies the range of values, then the boundary values that have just reached this range should be taken, as well as the values just beyond the bounds of this range as test input data

2) If the input conditions specify the number of values, then select the maximum number, the minimum number, the maximum number of one more than the minimum number of one less than the number as the test data

3) According to the specifications of each output condition, use Rule 1)

4) According to the specifications of each output condition, use Rule 2)

5) If the input field is an ordered set, select the first and last element of the collection as the test case

6) If the program uses an internal data structure, you should select the boundary value on the internal data structure as the test case

7) Analyze specifications to find other possible boundary conditions

3. Design test Cases using the boundary analysis method

  1) first determine the boundary condition data

2) Select a value that is exactly equal to, just above or below the boundary as a test, instead of picking a typical value or any value in an equivalence class.

4. Small instances

    • Problem Description: The Nextdata function contains three variables: Month,day,year, the output of the function is the day after the input date.
    • The input variable month,day,year is required to be an integer value, and the following conditions are met:
      • 1≤month≤12
      • 1≤day≤31
      • 1812≤year≤2012
    • Equivalence class Partitioning method: http://www.cnblogs.com/tju-crab/p/4354643.html In this blog application of equivalence class partitioning method in this case
    • Test Case Design:
Use Case number Input Expected output
Year Month Day
1 1811 2 1 Null
2 2013 2 1 Null
3 1812 0 1 Null
4 1812 13 1 Null
5 1812 2 0 Null
6 1812 2 29 1812/3/1
7 1812 2 30 Null
8 1812 3 0 Null
9 1812 3 31 1812/4/1
10 1812 3 32 Null
11 1812 4 0 Null
12 1812 4 30 1812/5/1
13 1812 4 31 Null
14 1813 2 28 1813/3/1
15 1813 2 29 Null
16 1812 12 31 1813/1/1
17 2012 12 31 2013/1/1

    • Code implementation:
BOOLIsleap (intYear ) {    if(Year%4!=0)return false; Else if(Year% -!=0)return true; Else if(Year% -==0)return true; Else return false;}voidNextdate (intMonthintDayintYear ) {    if(Year >=1812&& year <= -){        if(Month >=1&& Month <= A){            if(Month = =2){                if(Isleap (year)) {if(Day >=1&& Day < in) {cout<< year <<"years"<< Month <<"Month"<< Day +1<<"Day"<<Endl; }                    Else if(Day = = in) {cout<< year <<"years"<<3<<"Month"<<1<<"Day"<<Endl; }                }                Else{                    if(Day >=1&& Day < -) {cout<< year <<"years"<< Month <<"Month"<< Day +1<<"Day"<<Endl; }                    Else if(Day = = -) {cout<< year <<"years"<<3<<"Month"<<1<<"Day"<<Endl; }                }            }            Else if(Month = =2|| month = =4|| month = =6|| month = =9|| month = = One ){                if(Day >=1&& Day < -) {cout<< year <<"years"<< Month <<"Month"<< Day +1<<"Day"<<Endl; }                Else if(Day = = -) {cout<< year <<"years"<< month +1<<"Month"<<1<<"Day"<<Endl; }            }            Else{                if(Day >=1&& Day < to) {cout<< year <<"years"<< Month <<"Month"<< Day +1<<"Day"<<Endl; }                Else if(Day = = to){                    if(Month = = A) {cout<< year +1<<"years"<<1<<"Month"<<1<<"Day"<<Endl; }                    Else{cout<< year <<"years"<< month +1<<"Month"<<1<<"Day"<<Endl; }                }            }

  

"Software Testing" boundary value analysis method

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.