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

结对编程2单元测试

时间:2017-03-29 11:25:53      阅读:166      评论:0      收藏:0      [点我收藏+]

标签:height   cal   编程   时间   计划   类型   公约数   develop   bsp   

成员: 林 钊 -- 201421123105 吴世荣 -- 201421123119  王坤彬 -- 201421123108 

coding地址:https://coding.net/u/linzhao/p/UnitTest/git

需求分析:

1.整数加减乘除的测试;

2.分数加减乘除的测试;

3.最大公约数测试;

4.判断真分数测试;

计算模块:

public int gcd(int a, int b)//公约数
        {
            if (a == 0)
            {
                return b;
            }
           else if (b == 0)
            {
                return a;
            }
            else
            {
                return gcd(b % a, a);
            }
        }
        public int Calculate(int type, int op1, int op2)//整数四则运算
        {
            int result = 0;
            if (type == 1)
            {
                result = op1 + op2;
            }
            if (type == 2)
            {
                result = op1 - op2;
            }
            if (type == 3)
            {
                result = op1 * op2;
            }
            if (type == 4)
            {
                result = op1 / op2;
            }
            return result;
        }
        public string CalculateFengsu(int up1, int down1, int up2, int down2, int type)//分数四则运算
        {
            string result = "";
            if (type == 1)
            {
                up1 = (up1 * down2 + up2 * down1);
                down1 = down1 * down2;
                up2 = gcd(up1, down1);
                up1 = up1 / up2;
                down1 = down1 / up2;
                result = up1.ToString() + "/" + down1.ToString();
                return result;
            }
            if (type == 2)
            {
                up1 = (up1 * down2 - up2 * down1);
                down1 = down1 * down2;
                up2 = gcd(up1, down1);
                up1 = up1 / up2;
                down1 = down1 / up2;
                result = up1.ToString() + "/" + down1.ToString();
                return result;
            }
            if (type == 3)
            {
                up1 = up1 * up2;
                down1 = down1 * down2;
                up2 = gcd(up1, down1);
                up1 = up1 / up2;
                down1 = down1 / up2;
                result = up1.ToString() + "/" + down1.ToString();
                return result;
            }
            if (type == 4)
            {
                up1 = up1 * down2;
                down1 = down1 * up2;
                up2 = gcd(up1, down1);
                up1 = up1 / up2;
                down1 = down1 / up2;
                result = up1.ToString() + "/" + down1.ToString();
                return result;
             
            }
           
            return result;
        }
        public string CalculateZfengsu(int up1,int down1)//判断及生成真分数
        {
            string result = "true";
            int mid = 0;
            
                if (up1 > down1)
                {
                    mid = down1;
                    down1 = up1;
                    up1 = mid;
                    result = up1.ToString() + "/" + down1.ToString();
                    return result;
                }
                    if (up1 == down1)
                    {
                        down1 += 3;
                        result = up1.ToString() + "/" + down1.ToString();
                        return result;
                    }

                    
                
                
          
            return result;
        }

  一、公约数测试:

    gcd(int a, int b)

技术分享

      二、整数加减乘除测试:

Calculate(int type, int op1, int op2)其中type为运算类型,op1,op2为整数。

    技术分享

 

         三、分数四则运算:

 CalculateFengsu(int up1, int down1, int up2, int down2, int type)其中up1,up2为分子,down1,down2为分母,type为运算类型。

   技术分享

       四、判断真分数:

        

    CalculateZfengsu(int up1,int down1),up1,down1分别为分子分母。

   技术分享

         五、代码覆盖率:

       技术分享

         六、小结:

        刚开始做单元测试时,不知道从哪里下手,甚至把程序代码直接复制进去做单元测试,后来搜索网上的教程,在小组成员的帮助下才完成了单元测试。

        PSP:

        

 

PSP2.1

Personal Software Process Stages

Time Senior Student

Time

Planning

计划

0.5h

0.5h

· Estimate

估计这个任务需要多少时间

2h

2.5h

Development

开发

1h

1h

· Analysis

需求分析 (包括学习新技术)

15min

10min

· Design Spec

生成设计文档

5min

6min

· Design Review

设计复审

14min

16min

· Coding Standard

代码规范

5min

3min

· Design

具体设计

10min

12min

· Coding

具体编码

36min

21min

· Code Review

代码复审

7min

9min

· Test

测试(自我测试,修改代码,提交修改)

13min

21min

Reporting

报告

5min

6min

·

测试报告

3min

2min

·

计算工作量

2min

1min

·

并提出过程改进计划

3min

3min

 


        

 

结对编程2单元测试

标签:height   cal   编程   时间   计划   类型   公约数   develop   bsp   

原文地址:http://www.cnblogs.com/linzhao105/p/6638535.html

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