首页 > 其他 > 详细

软件测试上机作业

时间:2016-03-19 17:40:13      阅读:250      评论:0      收藏:0      [点我收藏+]

一、junit、hamcrest和eclemma的安装。

1.junit和hamcrest在新建了junitHw1工程后在build path里通过add external jars添加junit-4.12.jar和hamcrest-all-1.3.jar。

技术分享

2.eclemma在eclipse下点击help-eclipse marketplace-find-eclemma安装,重启eclipse。

技术分享

二、编程判断三角形是等边三角形、等腰三角形或不等边三角形。

public class triangle {
    private static int error = 0;
    private static int equilateral = 1;
    private static int isosceles = 2;
    private static int scalene = 3;
    

   
    public static int triangletype(int a,int b, int c){
        if(a <= 0 || b <= 0 || c <= 0){
             return 0; 
        }else if(a + b > c && a + c > b && b + c > a){
        
        if ( a == b && b == c){
            System.out.println("This is a equilateral triangle.");
            return 1;  
        }else if (a == b || a == c || b == c){
            System.out.println("This is a isosceles triangle.");
             return 2;
        }else {
            System.out.println("This is a scalene triangle.");
            return 3;
        }
        }else{
            return 0; 
       }
    }
        
}

创建测试类

public class triangle {
    private static int error = 0;
    private static int equilateral = 1;
    private static int isosceles = 2;
    private static int scalene = 3;
    

   
    public static int triangletype(int a,int b, int c){
        if(a <= 0 || b <= 0 || c <= 0){
             return 0; 
        }else if(a + b > c && a + c > b && b + c > a){
        
        if ( a == b && b == c){
            System.out.println("This is a equilateral triangle.");
            return 1;  
        }else if (a == b || a == c || b == c){
            System.out.println("This is a isosceles triangle.");
             return 2;
        }else {
            System.out.println("This is a scalene triangle.");
            return 3;
        }
        }else{
            return 0; 
       }
    }
        
}

三、测试结果

技术分享

技术分享

 

软件测试上机作业

原文:http://www.cnblogs.com/dpcn/p/5295477.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!