白盒测试和环复杂性

时间:2019-01-13 11:50:28

标签: unit-testing testing white-box-testing

我正在尝试解决有关白盒测试的问题,特别是在给出一段代码的情况下,我必须找到 cyclomatic complexity

这是给定的代码:

int[] v = ;
int s = 0;
if (v,length < 6 && v.length > 0)
       for (int i = 0 ; i < v.length ; i++) {
           if (v[i] == i)
              s++
    }
else s=-1; 
System.out.println(s);

我以这种方式重写代码以设计控制图:

int[] v = ;
int s = 0;
if (v.length < 6 && v.length > 0)
    int i = 0;
    while ( i < v.length-2 ) {
       if (v[i] == i)
          s++
    i++;
}
else s=-1;
System.out.println(s);

圈复杂度是 5 吗?

0 个答案:

没有答案
相关问题