Software Testing, Lab 1

Software Testing, Lab 1

一.实验要求:

  1. Install Junit(4.12), Hamcrest(1.3) with Eclipse
  2. Install Eclemma with Eclipse
  3. Write a java program for the triangle problem and test the program with Junit.

a)       Description of triangle problem:

Function triangle takes three integers a,b,c which are length of triangle sides; calculates whether the triangle is equilateral, isosceles, or scalene.

二.实验过程

1.JUnit、Hamcrest的安装:

从网上下载junit-4.12.jar 和 hamcrest-all-1.3.jar文件。

2.

1)在Eclipse中新建项目 (File - new - javaproject)

右键点击项目,选择Build Path - Configure Build Path

然后点击Libraries - Add External JARs,选择jar包打开,确认

2)Eclemma的安装:

在菜单栏选择Help - Eclipse Marketplace,搜索Eclemma,点击Install安装,重启Eclipse

3.代码编写

1)triangle.java

package hw;

public class triangle {

public static void main(String[] args) {

// TODO Auto-generated method stub

}

public int tri(int a,int b,int c){

int m=0;

if(a+b>c&&a+c>b&&b+c>a){

if(a==b&&b==c) m=1;  //equilateral

else if(a==b||b==c||a==c) m=2;  //isosceles

else m=3;  //scalene

}

else m=-1;

return m;

}

}

2)triangleTest.java

package hw;

import static org.junit.Assert.*;

import org.junit.Test;

public class triangleTest {

triangle t = new triangle();

@Test

public void test() {

int f = t.tri(1,1,1);

assertEquals( 1 , f );

f = t.tri(2,2,3);

assertEquals( 2 , f );

f = t.tri(2,3,4);

assertEquals( 3 , f );

f = t.tri(1,1,4);

assertEquals( -1 , f );

}

}

三.实验结果

各种情况的测试用例各一个,测试结果均通过

equilateral triangle返回1, isosceles triangle返回2,scalene triangle返回3,不能构成三角形则返回-1

测试结果如图

原文地址:https://www.cnblogs.com/zhaogang3015207537/p/8647656.html

时间: 2024-10-08 03:07:37

Software Testing, Lab 1的相关文章

SOFTWARE TESTING LAB 01

1.The brief description that you install junit, hamcrest and eclemma Junit和hamcrest直接从网上下载得到jar包,添加进项目的build PATH中:eclemma直接在eclipse中的Eclipse marketplace搜索安装得到. 2.The test result and coverage report (printscreen) of your tests on triangle problem.

Software Testing, Lab 1 Juint-and-Eclemma

Tasks: Install Junit(4.12), Hamcrest(1.3) with Eclipse Install Eclemma with Eclipse Write a java program for the triangle problem and test the program with Junit. a) Description of triangle problem: Function triangle takes three integers a,b,c which

Software Testing Techniques LAB 02: Selenium

1. Installing 1. Install firefox 38.5.1 2. Install SeleniumIDE    After installing, I set the view of toolbox, then we can see this 3. Install Selenium Client & WebDrive 4. Install Selenium Standalone Server 5. Installed Test After downloading we hav

Exploratory Software Testing

最近找到去年上半年看过一本关于测试方面书籍的总结笔记,一直放在我的个人U盘里,当时是用Xmind记录的,现在重新整理下分享给大家了! James A.Whittaker [美] 詹姆斯·惠特克(软件测试领域绝对的大师)著作<Exploratory Software Testing>,中文名<探索式软件测试>,记得当时被这本书深深吸引啦(我不知道有多少做测试的小伙伴看过这本书)!感觉是测试方面一本必不可少的书籍,瞬间感觉测试的魅力!废话不多说,直接来干货,希望可以给对探索式测试喜欢或

Software Testing Concepts

Software Testing Concepts

Software Testing Report,Triangle Problem, Lab 1, May 5th . 2016

首先要在eclipse里安装junit, hamcrest 和 eclemma 插件,可以在http://junit.org/junit4/ 上找到插件的下载,国内网估计下不了需要FQ,我就用的myeclipse,里面直接自带.http://www.myeclipsecn.com/ 这是myeclipse的官网链接. 然后就是开始编程序和测试程序具体的Java在github上,链接:https://github.com/DongArvin/Triangle-Test1 最后的测试结果是绿了.但没

Software Testing Lab2 (软件测试实验二) —— Selenium安装及入门

Download and install Firefox browser If you are the user of WINDOWS, there is a link available for you. Download and install selenium&firebug There is the way that how I finish this step. Open Firefox, click the buttom like picture. Then, search sele

Software Testing Homework of Lesson1

GitHub地址:https://github.com/Amnesia0704 文章主题:测试用例的自动生成 所选文章: MacHiry A, Tahiliani R, Naik M. Dynodroid: An input generation system for android apps[C]//Proceedings of the 2013 9th Joint Meeting on Foundations of Software Engineering. ACM, 2013: 224-2

HIT Software Construction Lab 3

? 2019年春季学期 计算机学院<软件构造>课程 Lab 3实验报告 姓名 刘帅 学号 1170500804 班号 1703008 电子邮件 [email protected] 手机号码 目录 1 实验目标概述··· 1 2 实验环境配置··· 1 3 实验过程··· 1 3.1 待开发的三个应用场景··· 1 3.2 基于语法的图数据输入··· 2 3.3 面向复用的设计:CircularOrbit· 2 3.4 面向复用的设计:Track· 4 3.5 面向复用的设计:L· 4 3.6