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

}

有问题及时交流!

相关推荐
在未来等你10 分钟前
互联网大厂Java求职面试:AI与大模型应用集成及云原生挑战
java·微服务·ai·kubernetes·大模型·embedding·spring ai
源码技术栈30 分钟前
SaaS基于云计算、大数据的Java云HIS平台信息化系统源码
java·大数据·云计算·云his·his系统·云医院·区域his
编程、小哥哥32 分钟前
互联网大厂Java面试:从Spring Boot到微服务架构的技术深挖
java·spring boot·redis·微服务·prometheus·面试技巧
揽你·入怀44 分钟前
数据结构:ArrayList简单实现与常见操作实例详解
java·开发语言
okok__TXF1 小时前
SpringBoot3+AI
java·人工智能·spring
AA-代码批发V哥1 小时前
Math工具类全面指南
java·开发语言·数学建模
caihuayuan53 小时前
生产模式下react项目报错minified react error #130的问题
java·大数据·spring boot·后端·课程设计
编程、小哥哥3 小时前
Java大厂面试:从Web框架到微服务技术的场景化提问与解析
java·spring boot·微服务·面试·技术栈·数据库设计·分布式系统
界面开发小八哥3 小时前
「Java EE开发指南」如何使用MyEclipse的可视化JSF编辑器设计JSP?(二)
java·ide·人工智能·java-ee·myeclipse
找不到、了5 小时前
Spring-Beans的生命周期的介绍
java·开发语言·spring