软件测试第一次实验/2016/3/18
2016-03-19 15:36
309 查看
IDE:intellija IDEA 15
1. Install junit,hamcrest,ec
工程目录新建lib文件夹,导入junit包
完成主体代码后右键创建test包,IDEA自动创建好test文件。
2. demo
方法主类:
测试:
实验结果截图
1. Install junit,hamcrest,ec
工程目录新建lib文件夹,导入junit包
完成主体代码后右键创建test包,IDEA自动创建好test文件。
2. demo
方法主类:
package com.dengsishun.util; import java.util.Arrays; /** * Created by Velacielad on 2016/3/18. */ public class Calculate { public boolean isTriangle(int a, int b, int c){ int[] edge = {a,b,c}; Arrays.sort(edge); if ( (edge[0]+edge[1]) <= edge[2]){ return false; } else return true; } public boolean isEqu(int a, int b, int c) { if (a == b && b == c){ return true; } else return false; } public boolean isIso(int a, int b,int c){ if(a == b || b == c || c == a){ return true; } else return false; } public String judgment(int a,int b,int c){ if (isTriangle(a,b,c)){ if (isEqu(a,b,c)){ return "equilateral"; } else if (isIso(a,b,c)){ return "isosceles"; } else return "scalene"; } else { return "error"; } } }
测试:
package com.dengsishun.util; import org.junit.Before; import org.junit.Test; import static org.junit.Assert.*; /** * Created by Velacielad on 2016/3/19. */ public class CalculateTest { private Calculate calculate; @Before public void setUp() throws Exception { calculate = new Calculate(); } @Test public void testJudgment() throws Exception { assertEquals("error",calculate.judgment(1,2,3)); assertEquals("equilateral",calculate.judgment(2,2,2)); assertEquals("isosceles",calculate.judgment(2,2,3)); assertEquals("scalene",calculate.judgment(4,2,3)); } }
实验结果截图
相关文章推荐
- 学习进度条——第三周
- 第三周总结PSP日志文件
- Windows API with VC6.0sp6Enterprise
- 专题:基础计算几何
- 入学考试 <0--1背包类问题>
- 前缀判断
- 第三周项目11-立方柱的类计算
- unity3d热更新插件uLua学习整理
- 欢迎使用CSDN-markdown编辑器
- (水)垒色子 蓝桥杯2015A组题
- jq 选择$(this)下的某个元素
- 51NOD 1467 旋转绳 二分查找 模拟
- spark概念、编程模型和模块概述
- Log API 性能总结
- MFC查找所有后缀文件获取文件大小读取特定位置数据
- 安卓linearLayout动态添加控件
- spark概念、编程模型和模块概述
- 反转链表
- php安装扩展错误:Cannot find config.m4. Make sure that you run /usr/local/bin/phpize in the top level sourc
- Udemy上Gephi教程笔记1