Software Testing lab01

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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.测试结果

技术分享

技术分享

技术分享

 

以上是关于Software Testing lab01的主要内容,如果未能解决你的问题,请参考以下文章

Software Testing Lab1

Software Testing Lab2

Software Testing -- LAB03-soot的使用

Software Testing, Lab 1

Software Testing, Lab 1

Software Testing_Lab 2_selenium