黑马2024AI+JavaWeb开发入门Day03-Maven-单元测试飞书作业
视频地址:哔哩哔哩
作业比较简单,随便写了写
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);
}
}
有问题及时交流!
原文地址:https://blog.csdn.net/weixin_46046293/article/details/144136871
免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!