zoukankan      html  css  js  c++  java
  • 逻辑覆盖的应用

    语句覆盖:abc  测试用例:X=1Y=2      

              aef  测试用例:X=4, Y=-1

              aeg  测试用例:X=4, Y=0

    分支覆盖:abc  测试用例:X=1Y=2      

              aef  测试用例:X=4, Y=-1

              aeg  测试用例:X=4, Y=0

              abd  测试用例:X=2, Y=1

    import java.util.Scanner;

    public class Da {

    /**

     * @param args

     */

    public static void main(String[] args) {

    // TODO Auto-generated method stub

    Scanner in = new Scanner(System.in); 

    System.out.print("请输入x: ");   

    int x = in.nextInt();

    Scanner in1 = new Scanner(System.in); 

    System.out.print("请输入y: ");   

    int y = in1.nextInt();

    Xiao xiao=new Xiao();

    xiao.Way(x, y);

    }

    }

    public class Xiao {

    public void  Way(int x,int y){

    if((x<4 || y>0)&&(y>1)){

    y=y+1;

    }

    else {

    if(x>=5){

    x=x-y;

    }

    else{

    x=x+y;

    }

    }

    if((x<4 || y>0)&&(y<1 || y==1)){

    }

    System.out.println("x的值为:"+x);

    System.out.println("y的值为:"+y);

    }

    }

    public class XiaoTest {

    @Test

    public void test() {

    System.out.println("语句覆盖:");

    Xiao xiao=new xiao();

    xiao.Way(1, 2);

           xiao.Way(4, -1);

           xiao.Way(4, 0);

    System.out.println("分支覆盖:");

    xiao.Way(1, 2);

           xiao.Way(4, -1);

           xiao.Way(4, 0);

        xiao.Way(2, 1);

    }

    }

  • 相关阅读:
    Test-Driven Development
    单元测试之道(使用NUnit)
    IoC--structuremap
    web.config的configSections节点
    【转】理解POCO
    js的call(obj,arg)学习笔记
    css隐藏滚动条方法
    regexp学习
    asp后台拼接百度ueditor编辑器过程
    php关键词construct和static
  • 原文地址:https://www.cnblogs.com/lingxiaohai/p/5387927.html
Copyright © 2011-2022 走看看