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");            
    }

  • 相关阅读:
    Access restriction: The type BASE64Encoder is not accessible due to restrict(转载)
    ECLIPSE控制台信息导出
    ZUI分页器的使用案例(ECLIPSE SMS项目)
    关于PLSQL启动用时较长的问题解决
    javax.naming.NamingException: Cannot create resource instance报错修改
    百度AI人脸识别的学习总结
    ECharts3.0饼状图使用问题总结
    jni开发
    AndroidStudio封装jar并混淆
    Androidstudio代码混淆
  • 原文地址:https://www.cnblogs.com/Carolinee/p/5417411.html
Copyright © 2011-2022 走看看