Use junit to test Trangle problem
Install Eclemma with Eclipse:
在eclipse下的help下的eclipseMakertPlace输入Eclemma,install 然后重启eclipse
代码:
Triangle.java:
package test2;
public class Triangle {
private int a,b,c;
public Triangle(int a, int b, int c) {
// TODO Auto-generated constructor stub
this.a=a;
this.b=b;
this.c=c;
}
public String derTerminTriangle(){
String type=" ";
if ((a+b<=c)||(a+c<=b)||(b+c<=a))
{
type="not Traingle";
}
else {
if ((a== b)&& (b==c)) {
type= "Equilateral";
} else if ((a==b)||(b==c)||(c==a))
{
type = "Isosceles";
} else {
type = "Scalene";
}
}
return type;
}
}
test.java:
package test2;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import java.util.HashSet;
import java.util.Set;
import org.junit.Test;
public class Test2 {
@Test
public void test() {
Triangle t3 = new Triangle(3,3,4);
String type3 = t3.derTerminTriangle();
assertEquals("Isosceles", type3);
}
@Test
public void test1() {
Triangle t2 = new Triangle(1,1,1);
String type2 = t2.derTerminTriangle();
assertEquals("Equilateral", type2);
}
@Test
public void test2() {
Triangle t3 = new Triangle(0,3,4);
String type3 = t3.derTerminTriangle();
assertEquals("not Traingle", type3);
}
@Test
public void test3() {
Triangle t3 = new Triangle(2,3,4);
String type3 = t3.derTerminTriangle();
assertEquals("Scalene", type3);
}
}
结果截图
转载于:https://www.cnblogs.com/maxrumi/p/5289553.html
Use junit to test Trangle problem相关推荐
- 软件测试实验1 — Junit 安装与 triangle problem 的测试
1. Install Junit(4.12), Hamcrest(1.3) with Eclipse 选中新建的项目,右键->Propertise->Java Build Path-&g ...
- 命令行执行Junit测试
[0]README 0.1)本文旨在给出如何在命令行中执行 Junit测试的steps: [1]在命令行中执行Junit测试 1)problem+solution: 1.1)problem: 1.2) ...
- 哈工大软件构造lab1
2020年春季学期 计算机学院<软件构造>课程 Lab 1实验报告 姓名 麦昌瀚 学号 190110920 班号 7 电子邮件 835889372@qq.com 手机号码 目录 1 实验目 ...
- surefire 拉起 junit 单元测试类 源码阅读(一)
根据surefire 拉起Junit单元测试类 输出的报错日志 跟踪执行过程: 日志1: java.lang.reflect.InvocationTargetExceptionat sun.refle ...
- junit单元测试断言_简而言之,JUnit:单元测试断言
junit单元测试断言 简而言之,本章涵盖了各种单元测试声明技术. 它详细说明了内置机制, Hamcrest匹配器和AssertJ断言的优缺点 . 正在进行的示例扩大了主题,并说明了如何创建和使用自定 ...
- 简而言之,JUnit:单元测试断言
简而言之,本章涵盖了各种单元测试断言技术. 它详细说明了内置机制, Hamcrest匹配器和AssertJ断言的优缺点 . 正在进行的示例扩大了该主题,并说明了如何创建和使用自定义匹配器/断言. 单元 ...
- 软件测试实验1:为三角形问题编写一个Java程序,并用Junit测试程序
实验报告 实验内容: 1.Install Junit(4.12), Hamcrest(1.3) with Eclipse 2.Install Eclemma with Eclipse 3.Write ...
- junit进行单元测试_通过JUnit规则轻松进行AppEngine单元测试
junit进行单元测试 by Ramesh Lingappa 通过拉梅什·林加帕(Ramesh Lingappa) 通过JUnit规则轻松进行AppEngine单元测试 (AppEngine unit ...
- How to Rerun Failed Tests in JUnit?
该帖转自其他出处 Sometimes due to some temporarily problems such as connection problems, server problems, br ...
最新文章
- Network POJ-3694
- 懒汉式(线程安全,同步代码块儿)
- Centos7: 配置IO调度
- Android 进程间通信——Service、Messenger
- mac下IDEA远程调试hive-2.2.0
- mysql可视化_Mysql学习
- 【学习笔记】平衡二叉树(AVL树)简介及其查找、插入、建立操作的实现
- JVM内存模型及垃圾回收机制
- FFmpeg开发(十)——Qt 实现FFmpeg下载m3u8视频
- meson编译C代码简单介绍及实例
- 微信号注册又将有新规定了
- zynq获取程序运行时间
- 其实特简单,Python 做一个漂亮女孩词云跳舞的视频
- jquery editplus
- 中控服务器PDS系统,bss中控服务器主机
- openssl生成证书linux,Linux下使用openssl生成证书
- 520表白浪漫的句子文案用便签记下来
- 任何产品需求,挖到最后都是人性
- 二叉树的遍历-先序遍历、中序遍历、后序遍历
- 蓝牙透传实验_蓝牙模块比较常见的通讯方式透传是什么
热门文章
- 猿创征文 | MySQL从基础到高级
- TCP 与 CPU 架构发展史
- 【论文阅读】智能设备中基于深度特征的语音情感识别
- 跑步用app轨迹画得比较准确的居然是“咕咚”
- DOM对象和JQuery对象别还傻傻分不清
- 教你文本聚类(参考http://www.kuqin.com/searchengine/20080511/8323.html)
- 商务英语转计算机,BEC商务英语
- 前端项目:从0开始实现一个合成大西瓜
- SDN网络的工作原理
- Context-free grammar 与 BNF,ASN.1