码迷,mamicode.com
首页 > 其他好文 > 详细

软件测试第三次作业

时间:2016-03-29 23:48:50      阅读:220      评论:0      收藏:0      [点我收藏+]

标签:

这次作业主要是根据代码,画出控制流图,并涉及计边覆盖,点覆盖,主路径的知识。

具体作业内容如下

/*******************************************************
     * Finds and prints n prime integers
     * Jeff Offutt, Spring 2003
     ******************************************************/
    public static void printPrimes (int n)
    {
        int curPrime; // Value currently considered for primeness
        int numPrimes; // Number of primes found so far.
        boolean isPrime; // Is curPrime prime?
        int [] primes = new int [MAXPRIMES]; // The list of prime numbers.
         
        // Initialize 2 into the list of primes.
        primes [0] = 2;
        numPrimes = 1;
        curPrime = 2;
        while (numPrimes < n)
        {
            curPrime++; // next number to consider ...
            isPrime = true;
            for (int i = 0; i <= numPrimes-1; i++)
            { // for each previous prime.
                if (curPrime%primes[i]==0)
                { // Found a divisor, curPrime is not prime.
                    isPrime = false;
                    break; // out of loop through primes.
                }
            }
            if (isPrime)
            { // save it!
                primes[numPrimes] = curPrime;
                numPrimes++;
            }
        } // End while
         
        // Print all the primes out.
        for (int i = 0; i <= numPrimes-1; i++)
        {
            System.out.println ("Prime: " + primes[i]);
        }
    } // end printPrimes

  一 画出控制流图

技术分享

二、设计一个t2=(n=5)比t1=(n=3)容易发现发现的错误

三、写一个测试用例,使相应的测试路径访问连接while语句开始到fot语句得边,而不用通过while的循环体

t:n=1

四、例举每个节点覆盖,边覆盖和主路径覆盖的TR

节点覆盖需求:{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}

边覆盖需求:{(1,2),(2,11),(2,3),(3,4),(4,5),(5,6),(5,7),(6,5),(6,9),(7,8),(7,2),(8,2),(9,10),(10,7),(11,12),(12,13),(12,15),(13,14),(14,12)}

主路径覆盖需求:

软件测试第三次作业

标签:

原文地址:http://www.cnblogs.com/GSONG/p/5335339.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!