zoukankan      html  css  js  c++  java
  • 软件测试(3)--coverage graph

    一、 Use the following method printPrimes() for questions a–d. 

    a)Draw the control flow graph for the printPrimes() method.

    b)Make sure the value of  MAXPRIMES equals 4, then there will be an out-of-array –bound fault when n = 5;

    c)当n=1时,会通过numPrimes>=直接从上图的2节点跳转到12节点,不经过while循环体内部。

    d)

    TR for nc:

     {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16}

    TR for ec:

    {(1,2),(2,3),(2,4),(3,5),(5,6),(5,7),(6,9)(6,8)(9,10),(10,5),(8,7),(7,11),(7,12),(11,13),(12,13),(13,2),(2,4),(4,15),(15,16),(16,4),(4,14)}

    TR for ppc:

    {(1,2,3,4,5,6,8),(1,2,3,4,5,6,7,9,10,11),(1,2,3,4,5,6,7,9,11),(1,2,3,4,5,9,11),(1,2,3,4,5,9,10,11),(5,6,8,5),(6,8,5,6),(8,5,6,8),(8,5,6,7,9,11),(8,5,6,7,9,10,11),(1,2,12,13,16),(1,2,12,13,14,15),(13,14,15,13),(14,15,13,14),(15,13,14,15),(14,15,13,16),(15,13,16)}

    二、Using Junit and Eclemma to test the method and cover all prime paths above

    package printPrimes;
    
    import static org.junit.Assert.*;
    
    import org.junit.After;
    import org.junit.Before;
    import org.junit.Test;
    
    public class primeTest {
    
        @Before
        public void setUp() throws Exception {
        }
    
        @After
        public void tearDown() throws Exception {
        }
    
        @Test
        public void test() {
            prime.printPrimes(3);
        }
    
    }

    测试结果

  • 相关阅读:
    一些Redis面试题
    PHP中类和对象
    PHP中普通方法和静态方法
    PHP中普通属性和静态属性
    PHP中对象的传值方式
    PHP创建对象的几种形式
    面向对象与面向过程思想区别
    mysql中联合查询
    mysql中用户和权限
    mysql中事务
  • 原文地址:https://www.cnblogs.com/Reallylzl/p/6546071.html
Copyright © 2011-2022 走看看