一、lombok的使用


默认jvm不解析第三方注解,需要手动开启

链式调用
 
 
二、juint单元测试
下载juint包
public class TestDemo {
    // 在每一个单元测试方法执行之前执行
    @Before
    public void before() {
        // 例如可以在before部分创建IO流
        System.out.println("before...");
    }
    // 在每一个单元测试方法执行之后执行
    @After
    public void after() {
        // 在最后的单元测试进行流的关闭
        System.out.println("after...");
    }
    @Test
    public void test1() {
        System.out.println("test1");
    }
    @Test
    public void test2() {
        System.out.println("test2");
    }
}三、单元测试
junit单元测试的方法要求"三无" : 无返回值 无参数 无静态。
    @Test
    public void test3() {
        // 测试驱动开发:先写测试代码,再写功能代码
        double discount = discount(100);
        // 断言
        assert discount == 90;
        double discount1 = discount(300);
        assert discount1 == 240;
    }
    public double discount(double money) {
        if (money >= 100 && money < 300) {
            money = money * 0.9;
        } else if (money >= 300 && money < 1000) {
            money = money * 0.8;
        } else if (money >= 1000) {
            money = money * 0.7;
        }
        return money;
    }如果单元测试中,测试的结果有误,就说明功能编写没有通过,否则通过。




















