黑马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);
    }

}

有问题及时交流!

相关推荐
BAStriver7 分钟前
PKIX path building failed问题小结
java·maven
welsonx28 分钟前
Android性能优化-Frida工具篇
java
圈圈编码33 分钟前
LeetCode Hot100刷题——合并两个有序链表
java·数据结构·算法·leetcode·链表
小前端大牛马40 分钟前
java教程笔记(十四)-线程池
java·笔记·python
魔镜魔镜_谁是世界上最漂亮的小仙女1 小时前
java-maven依赖管理
java·后端·全栈
Kim Jackson1 小时前
我的世界Java版1.21.4的Fabric模组开发教程(十三)自定义方块状态
java·游戏·fabric
异常君1 小时前
Java 双冒号(::)操作符实战解析与类型推断机制
java·代码规范·函数式编程
AA-代码批发V哥1 小时前
Java多线程实现之Thread类深度解析
java
快乐肚皮1 小时前
Spring Framework 6:核心升级特性
java·spring
&岁月不待人&1 小时前
实现弹窗随键盘上移居中
java·kotlin