Software Testing lab01

1.下载junit和hamcrest的jar包并引入项目

2.在eclipse商店中下载安装eclemma插件

3.编写判断三角形形状的代码

package lab1source;

public class src1 {
    public static String T(double a,double b,double c){
        double tem = Math.max(a, b);
        if(tem>c){
            if(tem==a){
                a = c;
            }else {
                b = c;
            }
            c = tem;
        }
        if(!(a+b>c&&Math.abs(a-b)<c)){
            return "not a triangle";
        }else if(a==b && a==c){
            return "equilateral triangle";
        }else if(a==b || a==c || b==c){
            return "isosceles triangle";
        }else return "scalene triangle";
        }
        public static void main(String[] args) {
            System.out.println(src1.T(3, 3, 3));
        }
}

4.完成测试类代码

package lab1source;

import static org.junit.Assert.*;

import org.junit.Test;

public class src1Test {
    src1 s1= new src1();
    @Test
    public void testT() {
        assertEquals("equilateral triangle",s1.T(3,3,3));
        assertEquals("isosceles triangle",s1.T(3,4,3));
        assertEquals("scalene triangle",s1.T(3,4,5));
    }

}

5.测试结果

时间: 2024-10-11 07:39:33

Software Testing lab01的相关文章

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, Lab 1

Software Testing, Lab 1 一.实验要求: 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 ta

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

Software Testing -- HW3

Using the following method printPrimes() for questions a-f below Prime.java package net.chenyuhong.junitTest; import java.awt.datatransfer.StringSelection; import java.util.Scanner; /** * @Title: Prime.java * @Package net.chenyuhong.junitTest * @Desc

software Testing Lab1

JUnit以及hamcrest-core-1.3 安装步骤 首先,新建一个java项目,名字叫triangle,然后右键,选择Properties,点击Java Build Path, 选择Libraries选项,点击右边的 Add library 选项,选择JUnit4, 于是JUnit软件包就被包含在这个项目里了. 再点击Add External Jars 按钮,选择已经下载好的hamcrest-core-1.3.jar的文件位置,hamcrest-core-1.3.jar就被包含进项目.

Software Testing 4th Assignment

EXERCISES Section 2.3 7(a)~(d) (a) (b)MAXPRIMES = 4 (c) t = (n = 1) (d) node coverage: TR = {0,1,2,3,4,5,6,7,8,9,10,11,12,13} edge coverage: TR = {(0,1),(1,2),(1,10),(2,3),(3,4),(4,5),(4,8),(5,6),(5,7),(6,8),(7,4),(8,1),(8,9),(9,1),(10,11),(10,12),(1