zoukankan      html  css  js  c++  java
  • 软件测试基础

    //对以下模块进行集成测试,分别用大爆炸模式和自顶向下模式进行测试。

    int moduleA(int x, int y)
    {
     int resA=0;
     if(x>100) resA=-1;
     else if(x>0) resA=moduleB(x, y);
     else if(x==0) resA=moduleC(y);
     else if(x>-100) resA=moduleD(x, y);
     else resA=-1;
     return resA;
    }
    int moduleB(int x, int y)
    {
     int resB=0;
     if(x==5) resB=-1;
     else resB=moduleE(y);
     return resB;
    }

    int moduleC(int x)
    {
     return x*x+2;
    }

    int moduleD(int x, int y)
    {
     int resD=0;
     if(x==-1) resD=-1;
     else resD=moduleF(y);
     return resD;
    }

    int moduleE(int x)
    {
     return x+1;
    }

    int moduleF(int x)
    {
     return 1-x;
    }

    首先,画出模块之间的关系图

    1.大爆炸的测试

    Step1:
          接收测试用例的输入、预期结果; 
    Step2:
          调用被测对象;
    Step3:
          比较预期结果和实际结果  相同: PASS 不同:Fail;

    bigbang_driver(int x,int y,int expRes){
      int actRes=moduleA(x,y);
      if(actRes==expRes)
      printf("Testcase Pass! ");
      else
      printf("Testcase Fail! ");
     }            
     main(){
       bigbang_driver(1,9,10);    //A-B,B-E
       bigbang_driver(0,3,11);    //A-C
       bigbang_driver(-99,9,-8);    //A-D,D-F
      
       system("Pause");
    }       
        

    2.自顶向下测试

    Step1:
           测试AB,设计AB的驱动,针对CDE分别打桩;
    Step2:
           测试ABE,利用AB的驱动,针对CD打桩;
    Step3:
           测试ABEC,利用AB的驱动,针对D打桩;

    topdown_driver(int x,int y,int expRes){
      int actRes=moduleA(x,y);
      if(actRes==expRes)
      printf("Testcase Pass! ");
      else
      printf("Testcase Fail! ");
    }             

    int moduleC_stub(int x)
    {
     //return x*x+2;
     if(x==5) return 27;  
    }


    int moduleD_stub(int x, int y)
    {
        /* 
     int resD=0;
     if(x==-1) resD=-1;
     else resD=moduleF(y);
     return resD;
     */ 
     if(x==-99&&y==8) return -7; 
    }
    /* step1
    int moduleE_stub(int x)
    {
     //return x+1;
     if(x==9) return 10; 
    }
    */

    //step2
    int moduleE(int x)
    {
     return x+1;
    }

    main(){
       topdown_driver(1,9,10);    //AB-E
       topdown_driver(0,5,27);    //AB-C
       topdown_driver(-99,8,-7);  //AB-D
       system("Pause");            
    }

  • 相关阅读:
    D3D中的Alpha颜色混合(1)
    最小的MFC程序
    命名空间规则【内部】
    能登陆QQ,打不开网页
    .net重要的开源组件[更新中]
    validateRequest="false"属性及xss攻击
    RSS介绍
    Virtual、Override和New关键字的使用
    SQL语句精妙集合
    绝好的软件集合
  • 原文地址:https://www.cnblogs.com/Carolinee/p/5417411.html
Copyright © 2011-2022 走看看