黑马2024AI+JavaWeb开发入门Day03-Maven-单元测试飞书作业

视频地址:哔哩哔哩

讲义作业飞书地址:飞书

作业比较简单,随便写了写

java 复制代码
package org.example;

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;

public class EmpServiceTest {
    public EmpService empService;
    @BeforeEach
    public void testBefore(){
        empService = new EmpService();
    }

    @Test
    public void testIsBeijing(){
        boolean result = empService.isBeijing("110101199001011234");
        System.out.println(result);
        Assertions.assertEquals(true, result);
    }

    @Test
    public void testGetAge(){
        Integer result = empService.getAge("110101199001011234");
        System.out.println(result);
        Assertions.assertEquals(34, result);
    }

    @Test
    public void testGetGender(){
        String result = empService.getGender("110101199001011234");
        System.out.println(result);
        Assertions.assertEquals("男", result);
    }

    @Test
    public void testGetYear(){
        String result = empService.getYear("110101199001011234");
        System.out.println(result);
        Assertions.assertEquals("1990", result);
    }

    @Test
    public void testGetMonth(){
        String result = empService.getMonth("110101199001011234");
        System.out.println(result);
        Assertions.assertEquals("01", result);
    }

    @ParameterizedTest
    @CsvSource({
            "610110201909091231, 5",
            "110110201509091109, 9",
            "510310198812120931, 35"
    })
    public void testGetAge2(String idcard, Integer age){
        Integer result = empService.getAge(idcard);
        System.out.println(result);
        Assertions.assertEquals(age, result);
    }

}

有问题及时交流!

相关推荐
零雲31 分钟前
java面试:了解抽象类与接口么?讲一讲它们的区别
java·开发语言·面试
左左右右左右摇晃3 小时前
Java并发——synchronized锁
java·开发语言
sxlishaobin4 小时前
Java I/O 模型详解:BIO、NIO、AIO
java·开发语言·nio
彭于晏Yan4 小时前
Spring AI(二):入门使用
java·spring boot·spring·ai
有一个好名字5 小时前
vibe codeing 开发流程
java
兑生5 小时前
【灵神题单·贪心】3745. 三元素表达式的最大值 | 排序贪心 | Java
java·开发语言
polaris06305 小时前
Windows操作系统部署Tomcat详细讲解
java·windows·tomcat
卓怡学长5 小时前
m280本科生导师指导平台
java·数据库·spring·tomcat·maven·intellij-idea
一直都在5725 小时前
Java死锁
java·开发语言
我真会写代码6 小时前
深度解析并发编程锁升级:从偏向锁到重量级锁,底层原理+面试考点全拆解
java·并发编程·