当前位置:首页>java>Java编程技巧之单元测试用例简化方法(内含案例)

Java编程技巧之单元测试用例简化方法(内含案例)

  • 2026-01-14 08:21:50
Java编程技巧之单元测试用例简化方法(内含案例)

前言

清代谴责小说家吴趼人在《痛史》中写道:“卷帙浩繁,望而生畏
意思是:“ 一部书的篇幅太长,让人看见就害怕。”编写单元测试用例也是如此,如果单元测试用例写起来又长又复杂,自然而然地会让人“望而生畏”,于是开始反感甚至于最终放弃。为了便于Java单元测试的推广,作者总结了十余种测试用例的简化方法,希望能够让大家编写单元测试用例时——“化繁为简、下笔如神”。

一、简化模拟数据对象

1.1. 利用JSON反序列化简化数据对象赋值语句

利用JSON反序列化,可以简化大量的数据对象赋值语句。首先,加载JSON资源文件为JSON字符串;然后,通过JSON反序列化JSON字符串为数据对象;最后,用该数据对象来模拟类属性值、方法参数值和方法返回值。
原始用例:
List<UserCreateVO> userCreateList = new ArrayList<>();UserCreateVO userCreate0 = new UserCreateVO();userCreate0.setName("Changyi");... // 约几十行userCreateList.add(userCreate0);UserCreateVO userCreate1 = new UserCreateVO();userCreate1.setName("Tester");... // 约几十行userCreateList.add(userCreate1);... // 约几十条userService.batchCreate(userCreateList);
简化用例:
String text = ResourceHelper.getResourceAsString(getClass(), path + "userCreateList.json");List<UserCreateVO> userCreateList = JSON.parseArray(text, UserCreateVO.class);userService.batchCreate(userCreateList);
1.2. 利用虚拟数据对象简化返回值模拟语句

有时候,模拟的方法返回值在测试方法内部并不发生修改,只是起到一个透传的作用而已。对于这种情况,我们只需要模拟一个对象实例,但并不关心其内部具体内容。所以,可以直接用虚拟数据对象替换真实数据对象,从而简化了返回值模拟语句。
被测代码:
@GetMapping("/get")public ExampleResult<UserVO> getUser(@RequestParam(value = "userId", required = true) Long userId) {    UserVO user = userService.getUser(userId);    return ExampleResult.success(user);}

原始用例:

// 模拟依赖方法String path = RESOURCE_PATH + "testGetUser/";String text = ResourceHelper.getResourceAsString(getClass(), path + "user.json");UserVO user = JSON.parseObject(text, UserVO.class);Mockito.doReturn(user).when(userService).getUser(user.getId());// 调用测试方法ExampleResult<UserVO> result = userController.getUser(user.getId());Assert.assertEquals("结果编码不一致", ResultCode.SUCCESS.getCode(), result.getCode());Assert.assertEquals("结果数据不一致", user, result.getData());

简化用例:

// 模拟依赖方法Long userId = 12345L;UserVO user = Mockito.mock(UserVO.class); // 也可以使用new UserVO()Mockito.doReturn(user).when(userService).getUser(userId);// 调用测试方法ExampleResult<UserVO> result = userController.getUser(userId);Assert.assertEquals("结果编码不一致", ResultCode.SUCCESS.getCode(), result.getCode());Assert.assertSame("结果数据不一致", user, result.getData());

1.3. 利用虚拟数据对象简化参数值模拟语句

有时候,模拟的方法参数值在测试方法内部并不发生修改,只是起到一个透传的作用而已。对于这种情况,我们只需要模拟一个对象实例,但并不关心其内部具体内容。所以,可以直接用虚拟数据对象替换真实数据对象,从而简化参数值模拟语句。
被测代码:
@GetMapping("/create")public ExampleResult<Void> createUser(@Valid @RequestBody UserCreateVO userCreate) {    userService.createUser(userCreate);    return ExampleResult.success();}

原始用例:

// 调用测试方法String path = RESOURCE_PATH + "testCreateUser/";String text = ResourceHelper.getResourceAsString(getClass(), path + "userCreate.json");UserCreateVO userCreate = JSON.parseObject(text, UserCreateVO.class);ExampleResult<Void> result = userController.createUser(userCreate);Assert.assertEquals("结果编码不一致", ResultCode.SUCCESS.getCode(), result.getCode());// 验证依赖方法Mockito.verify(userService).createUser(userCreate);

简化用例:

// 调用测试方法UserCreateVO userCreate = Mockito.mock(UserCreateVO.class); // 也可以使用new UserCreateVO()ExampleResult<Void> result = userController.createUser(userCreate);Assert.assertEquals("结果编码不一致", ResultCode.SUCCESS.getCode(), result.getCode());// 验证依赖方法Mockito.verify(userService).createUser(userCreate);

二、简化模拟依赖方法

2.1. 利用默认返回值简化模拟依赖方法

模拟对象的方法是具有默认返回值的:当方法返回类型为基础类型时,默认返回值是0或false;当方法返回类型为对象类型时,默认返回值是null。在测试用例中,当需要模拟方法返回值为上述默认值时,我们可以省略这些模拟方法语句。当然,显式地写上这些模拟方法语句,可以让测试用例变得更便于理解。
原始用例:
Mockito.doReturn(false).when(userDAO).existName(userName);Mockito.doReturn(0L).when(userDAO).countByCompany(companyId);Mockito.doReturn(null).when(userDAO).queryByCompany(companyId, startIndex, pageSize);

简化用例:

可以把以上模拟方法语句直接删除。

2.2. 利用任意匹配参数简化模拟依赖方法

在模拟依赖方法时,有些参数需要使用到后面加载的数据对象,比如下面案例中的UserCreateVO的name属性值。这样,我们就需要提前加载UserCreateVO对象,既让模拟方法语句看起来比较繁琐,又让加载UserCreateVO对象语句和使用UserCreateVO对象语句分离(优秀的代码,变量定义和初始化一般紧挨着变量使用代码)。
利用任意匹配参数就可以解决这些问题,使测试用例变得更简洁更便于维护。但是要注意,验证该方法时,不能再用任意匹配参数去验证,必须使用真实的值去验证。
原始用例:
// 模拟依赖方法String path = RESOURCE_PATH + "testCreateUserWithSuccess/";String text = ResourceHelper.getResourceAsString(getClass(), path + "userCreateVO.json");UserCreateVO userCreateVO = JSON.parseObject(text, UserCreateVO.class);Mockito.doReturn(false).when(userDAO).existName(userCreateVO.getName());...// 调用测试方法Assert.assertEquals("用户标识不一致", userId, userService.createUser(userCreateVO));// 验证依赖方法Mockito.verify(userDAO).existName(userCreateVO.getName());...

简化用例:

// 模拟依赖方法Mockito.doReturn(false).when(userDAO).existName(Mockito.anyString());...// 调用测试方法String path = RESOURCE_PATH + "testCreateUserWithSuccess/";String text = ResourceHelper.getResourceAsString(getClass(), path + "userCreateVO.json");UserCreateVO userCreateVO = JSON.parseObject(text, UserCreateVO.class);Assert.assertEquals("用户标识不一致", userId, userService.createUser(userCreateVO));// 验证依赖方法Mockito.verify(userDAO).existName(userCreateVO.getName());...
2.3. 利用do/thenAnswer简化模拟依赖方法

当一个方法需要调用多次,但返回值跟调用顺序无关,只跟输入参数有关的时,可以用映射来模拟方法不同返回值。先加载一个映射JSON资源文件,通过JSON.parseObject方法转化为映射,然后利用Mockito的doAnswer-when或when-thenAnswer语法来模拟方法返回对应值(根据指定参数返回映射中的对应值)。
原始用例:
String text = ResourceHelper.getResourceAsString(getClass(), path + "user1.json");UserDO user1 = JSON.parseObject(text, UserDO.class);Mockito.doReturn(user1).when(userDAO).get(user1.getId());text = ResourceHelper.getResourceAsString(getClass(), path + "user2.json");UserDO user2 = JSON.parseObject(text, UserDO.class);Mockito.doReturn(user2).when(userDAO).get(user2.getId());...

简化用例:

String text = ResourceHelper.getResourceAsString(getClass(), path + "userMap.json");Map<Long, UserDO> userMap = JSON.parseObject(text, new TypeReference<Map<Long, UserDO>>() {});Mockito.doAnswer(invocation -> userMap.get(invocation.getArgument(0))).when(userDAO).get(Mockito.anyLong());

2.4. 利用Mock参数简化模拟链式调用方法

在日常编码过程中,很多人都喜欢使用链式调用,这样可以让代码变得更简洁。对于链式调用,Mockito提供了更加简便的单元测试方法——提供Mockito.RETURNS_DEEP_STUBS参数,实现链式调用的对象自动mock。
被测代码:
public void addCorsMappings(CorsRegistry registry) {    registry.addMapping("/**")        .allowedOrigins("*")        .allowedMethods("GET", "HEAD", "POST", "PUT", "DELETE", "OPTIONS")        .allowCredentials(true)        .maxAge(MAX_AGE)        .allowedHeaders("*");}

原始用例:

正常情况下,每一个依赖对象及其调用方法都要mock,编写的代码如下:
@Testpublic void testAddCorsMappings() {    // 模拟依赖方法    CorsRegistry registry = Mockito.mock(CorsRegistry.class);    CorsRegistration registration = Mockito.mock(CorsRegistration.class);    Mockito.doReturn(registration).when(registry).addMapping(Mockito.anyString());    Mockito.doReturn(registration).when(registration).allowedOrigins(Mockito.any());    Mockito.doReturn(registration).when(registration).allowedMethods(Mockito.any());    Mockito.doReturn(registration).when(registration).allowCredentials(Mockito.anyBoolean());    Mockito.doReturn(registration).when(registration).maxAge(Mockito.anyLong());    Mockito.doReturn(registration).when(registration).allowedHeaders(Mockito.any());    // 调用测试方法    webAuthInterceptConfig.addCorsMappings(registry);    // 验证依赖方法    Mockito.verify(registry).addMapping("/**");    Mockito.verify(registration).allowedOrigins("*");    Mockito.verify(registration).allowedMethods("GET", "HEAD", "POST", "PUT", "DELETE", "OPTIONS");    Mockito.verify(registration).allowCredentials(true);    Mockito.verify(registration).maxAge(3600L);    Mockito.verify(registration).allowedHeaders("*");}

简化用例:

利用Mockito.RETURNS_SELF参数编写的测试用例如下:
@Testpublic void testAddCorsMapping() {    // 模拟依赖方法    CorsRegistry registry = Mockito.mock(CorsRegistry.class);    CorsRegistration registration = Mockito.mock(CorsRegistration.class, Answers.RETURNS_SELF);    Mockito.doReturn(registration).when(registry).addMapping(Mockito.anyString());    // 调用测试方法    webAuthInterceptConfig.addCorsMappings(registry);    // 验证依赖方法    Mockito.verify(registry).addMapping("/**");    Mockito.verify(registration).allowedOrigins("*");    Mockito.verify(registration).allowedMethods("GET", "HEAD", "POST", "PUT", "DELETE", "OPTIONS");    Mockito.verify(registration).allowCredentials(true);    Mockito.verify(registration).maxAge(3600L);    Mockito.verify(registration).allowedHeaders("*");}

代码说明:

  1. 在mock对象时,对于自返回对象,需要指定Mockito.RETURNS_SELF参数;

  2. 在mock方法时,无需对自返回对象进行mock方法,因为框架已经mock方法返回了自身;

  3. 在verify方法时,可以像普通测试法一样优美地验证所有方法调用。

参数说明:
在mock参数中,有2个参数适合于mock链式调用:
  1. RETURNS_SELF参数mock调用方法语句最少,适合于链式调用返回相同值;

  2. RETURNS_DEEP_STUBS参数mock调用方法语句较少,适合于链式调用返回不同值。

三、简化验证数据对象

3.1. 利用JSON序列化简化数据对象验证语句

利用JSON反序列化,可以简化大量的数据对象验证语句。首先,加载JSON资源文件为JSON字符串;然后,通过JSON序列化数据对象(方法返回值或方法参数值)为JSON字符串;最后,再验证两个JSON字符串是否一致。
原始用例:
List<UserVO> userList = userService.queryByCompanyId(companyId);UserVO user0 = userList.get(0);Assert.assertEquals("name不一致", "Changyi", user0.getName());... // 约几十行UserVO user1 = userList.get(1);Assert.assertEquals("name不一致", "Tester", user1.getName());... // 约几十行... // 约几十条

简化用例:

List<UserVO> userList = userService.queryByCompanyId(companyId);String text = ResourceHelper.getResourceAsString(getClass(), path + "userList.json");Assert.assertEquals("用户列表不一致", text, JSON.toJSONString(userList));
小知识点:
  1. 如果数据对象中存在Map对象,为了保证序列化后的字段顺序一致,需要添加SerializerFeature.MapSortField特征。

JSON.toJSONString(userMapSerializerFeature.MapSortField);
  1. 如果数据对象中存在随机对象,比如时间、随机数等,需要使用过滤器过滤这些字段。
排除所有类的属性字段:
List<UserVO> userList = ...;SimplePropertyPreFilter filter = new SimplePropertyPreFilter();filter.getExcludes().addAll(Arrays.asList("gmtCreate", "gmtModified"));Assert.assertEquals("用户信息不一致", text, JSON.toJSONString(user, filter));

排除单个类的属性字段:

List<UserVO> userList = ...;SimplePropertyPreFilter filter = new SimplePropertyPreFilter(UserVO.class);filter.getExcludes().addAll(Arrays.asList("gmtCreate", "gmtModified"));Assert.assertEquals("用户信息不一致", text, JSON.toJSONString(user, filter));

排除多个类的属性字段:

Pair<UserVO, CompanyVO> userCompanyPair = ...;SimplePropertyPreFilter userFilter = new SimplePropertyPreFilter(UserVO.class);userFilter.getExcludes().addAll(Arrays.asList("gmtCreate", "gmtModified"));SimplePropertyPreFilter companyFilter = new SimplePropertyPreFilter(CompanyVO.class);companyFilter.getExcludes().addAll(Arrays.asList("createTime", "modifyTime"));Assert.assertEquals("用户公司对不一致", text, JSON.toJSONString(userCompanyPair, new SerializeFilter[]{userFilter, companyFilter});

3.2. 利用数据对象相等简化返回值验证语句

在用Assert.assertEquals方法验证返回值时,可以直接指定基础类型值或数据对象实例。当数据对象实例不一致时,只要其数据对象相等(equals比较返回true),Assert.assertEquals方法也会认为其是相等的。所以,可以利用数据对象相等来替换JSON字符串验证,从而简化测试方法返回值验证语句。
原始用例:
List<Long> userIdList = userService.getAllUserIds(companyId);String text = JSON.toJSONString(Arrays.asList(1L, 2L, 3L));Assert.assertEquals("用户标识列表不一致", text, JSON.toJSONString(userIdList));

简化用例:

List<Long> userIdList = userService.getAllUserIds(companyId);Assert.assertEquals("用户标识列表不一致", Arrays.asList(1L, 2L, 3L), userIdList);
小知识点:
  1. Assert.assertSame用于相同类实例验证——类实例相同;

  2. Assert.assertEquals用于相等类实例验证——类实例相同或相等(equals为true)。

注意:
这里不建议为了使用这个功能而重载equals方法,只建议针对相同或已重载equals方法的类实例使用。而针对未重载equals方法的类实例,建议转化为JSON字符串后再验证。

3.3. 利用数据对象相等简化参数值验证语句

在用Mockito.verify方法验证依赖方法参数时,可以直接指定基础类型值或数据对象实例。当数据对象实例不一致时,只要其数据对象相等(equals比较返回true),Mockito.verify方法也会认为其是相等的。所以,可以利用数据对象相等来替换ArgumentCaptor参数捕获,从而简化依赖方法参数值验证语句。
原始用例:
ArgumentCaptor<List<Long>> userIdListCaptor = CastHelper.cast(ArgumentCaptor.forClass(List.class));Mockito.verify(userDAO).batchDelete(userIdListCaptor.capture());Assert.assertEquals("用户标识列表不一致", Arrays.asList(1L, 2L, 3L), userIdListCaptor.getValue());

简化用例:

Mockito.verify(userDAO).batchDelete(Arrays.asList(1L, 2L, 3L));

注意:

这里不建议为了使用这个功能而重载equals方法,只建议针对相同或已重载equals方法的类实例使用。而针对未重载equals方法的类实例,建议先捕获参数转化为JSON字符串后再验证。

四、简化验证依赖方法

4.1. 利用ArgumentCaptor简化验证依赖方法

当一个模拟方法被多次调用时,需要对每一次模拟方法调用进行验证,就显得模拟方法验证代码过于繁琐。这里,可以通过ArgumentCaptor来捕获参数值,然后通过getAllValues方法来获取参数值列表,最后对参数值列表进行统一验证即可。其中,即验证了方法调用次数(列表长度),又验证了方法参数值(列表数据)。
原始用例:
Mockito.verify(userDAO).get(user1.getId());Mockito.verify(userDAO).get(user2.getId());...

简化用例:

ArgumentCaptor<Long> userIdCaptor = ArgumentCaptor.forClass(Long.class);Mockito.verify(userDAO, Mockito.atLeastOnce()).get(userIdCaptor.capture());text = ResourceHelper.getResourceAsString(getClass(), path + "userIdList.json");Assert.assertEquals("用户标识列表不一致", text, JSON.toJSONString(userIdCaptor.getAllValues()));

五、简化单元测试用例

5.1. 利用直接测试私有方法简化单元测试用例

习惯性地,我们通过构造共有方法的测试用例,来覆盖公有方法及其私有方法的所有分支。这种方式没有问题,但有时候显得测试用例比较繁琐。我们可以直接测试私有方法,单独对私有方法进行全覆盖,从而减少对公有方法的测试用例。
被测代码:
public UserVO getUser(Long userId) {    // 获取用户信息    UserDO userDO = userDAO.get(userId);    if (Objects.isNull(userDO)) {        throw new ExampleException(ErrorCode.OBJECT_NONEXIST, "用户不存在");    }    // 返回用户信息    UserVO userVO = new UserVO();    userVO.setId(userDO.getId());    userVO.setName(userDO.getName());    userVO.setVip(isVip(userDO.getRoleIdList()));    ...    return userVO;}private static boolean isVip(List<Long> roleIdList) {    for (Long roleId : roleIdList) {        if (VIP_ROLE_ID_SET.contains(roleId)) {            return true;        }    }    return false;}

原始用例:

@Testpublic void testGetUserWithVip() {    // 模拟依赖方法    String path = RESOURCE_PATH + "testGetUserWithVip/";    String text = ResourceHelper.getResourceAsString(getClass(), path + "userDO.json");    UserDO userDO = JSON.parseObject(text, UserDO.class);    Mockito.doReturn(userDO).when(userDAO).get(userDO.getId());    // 调用测试方法    UserVO userVO = userService.getUser(userDO.getId());    text = ResourceHelper.getResourceAsString(getClass(), path + "userVO.json");    Assert.assertEquals("用户信息不一致", text, JSON.toJSONString(userVO));    // 验证依赖方法    Mockito.verify(userDAO).get(userDO.getId());}@Testpublic void testGetUserWithNotVip() {    ... // 代码跟testGetUserWithVip一致, 只是测试数据不同而已}

简化用例:

@Testpublic void testGetUserWithNormal() {    ... // 代码跟原testGetUserWithVip一致}@Testpublic void testIsVipWithTrue() throws Exception {    List<Long> roleIdList = ...; // 包含VIP角色标识    Assert.assertTrue("返回值不为真", Whitebox.invokeMethod(UserService.class, "isVip", roleIdList));}@Testpublic void testIsVipWithFalse() throws Exception {    List<Long> roleIdList = ...; // 不含VIP角色标识    Assert.assertFalse("返回值不为假", Whitebox.invokeMethod(UserService.class, "isVip", roleIdList));}

5.2. 利用JUnit的参数化测试简化单元测试用例

有时候我们会发现,同一方法的在不同场景下的单元测试,除了加载的数据不同之外,单元测试用例的代码基本完全一致。我们可以这样分析:虽然单元测试用例的场景不一样——执行代码的分支不一样,调用方法方法的顺序、次数、返回值不一样;但是,其调用的依赖方法的数量是完全一致的;所以,最终写出来的单元测试用例的代码也是完全一致的。这时,我们就可以采用JUnit的参数化测试来简化单元测试用例。
被测代码:
同上一章的测试代码。
原始用例:
同上一章的原始用例。
简化用例:
@ParameterizedTest@ValueSource(strings = { "vip/", "notVip/"})public void testGetUserWithNormal(String dir) {    // 模拟依赖方法    String path = RESOURCE_PATH + "testGetUserWithNormal/" + dir;    String text = ResourceHelper.getResourceAsString(getClass(), path + "userDO.json");    UserDO userDO = JSON.parseObject(text, UserDO.class);    Mockito.doReturn(userDO).when(userDAO).get(userDO.getId());    // 调用测试方法    UserVO userVO = userService.getUser(userDO.getId());    text = ResourceHelper.getResourceAsString(getClass(), path + "userVO.json");    Assert.assertEquals("用户信息不一致", text, JSON.toJSONString(userVO));    // 验证依赖方法    Mockito.verify(userDAO).get(userDO.getId());}

如上简化用例所示:在资源目录testGetUserWithNormal中创建了两个目录vip和notVip,用于存储相同名称的JSON文件userDO.json和userVO.json,但是其文件内容根据场景又有所不同。

备注:本案例采用JUnit5.0的参数化测试新特性。

后记

本文只是抛砖引玉,起了个话题打了个底,希望大家继续深挖并完善。

往期系列文章:

收藏!Java编程技巧之单元测试用例编写流程

Java单元测试技巧之JSON序列化

那些年,我们写过的无效单元测试

Java工程师必读手册

工匠追求“术”到极致,其实就是在寻“道”,且离悟“道”也就不远了,亦或是已经得道,这就是“工匠精神”——一种追求“以术得道”的精神。 如果一个工匠只满足于“术”,不能追求“术”到极致去悟“道”,那只是一个靠“术”养家糊口的工匠而已。作者根据多年来的实践探索,总结了大量的Java编码之“术”,试图阐述出心中的Java编码之“道”。

点击阅读原文查看详情。

最新文章

随机文章

基本 文件 流程 错误 SQL 调试
  1. 请求信息 : 2026-02-10 07:36:01 HTTP/2.0 GET : https://f.mffb.com.cn/a/459033.html
  2. 运行时间 : 0.091188s [ 吞吐率:10.97req/s ] 内存消耗:4,828.58kb 文件加载:140
  3. 缓存信息 : 0 reads,0 writes
  4. 会话信息 : SESSION_ID=18792a78d7c15f6d148abb97f1523b2e
  1. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/public/index.php ( 0.79 KB )
  2. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/autoload.php ( 0.17 KB )
  3. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/autoload_real.php ( 2.49 KB )
  4. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/platform_check.php ( 0.90 KB )
  5. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/ClassLoader.php ( 14.03 KB )
  6. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/autoload_static.php ( 4.90 KB )
  7. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper.php ( 8.34 KB )
  8. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-validate/src/helper.php ( 2.19 KB )
  9. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/helper.php ( 1.47 KB )
  10. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/stubs/load_stubs.php ( 0.16 KB )
  11. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Exception.php ( 1.69 KB )
  12. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-container/src/Facade.php ( 2.71 KB )
  13. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/deprecation-contracts/function.php ( 0.99 KB )
  14. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/polyfill-mbstring/bootstrap.php ( 8.26 KB )
  15. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/polyfill-mbstring/bootstrap80.php ( 9.78 KB )
  16. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/var-dumper/Resources/functions/dump.php ( 1.49 KB )
  17. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-dumper/src/helper.php ( 0.18 KB )
  18. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/var-dumper/VarDumper.php ( 4.30 KB )
  19. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/App.php ( 15.30 KB )
  20. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-container/src/Container.php ( 15.76 KB )
  21. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/container/src/ContainerInterface.php ( 1.02 KB )
  22. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/provider.php ( 0.19 KB )
  23. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Http.php ( 6.04 KB )
  24. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper/Str.php ( 7.29 KB )
  25. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Env.php ( 4.68 KB )
  26. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/common.php ( 0.03 KB )
  27. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/helper.php ( 18.78 KB )
  28. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Config.php ( 5.54 KB )
  29. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/app.php ( 0.95 KB )
  30. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/cache.php ( 0.78 KB )
  31. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/console.php ( 0.23 KB )
  32. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/cookie.php ( 0.56 KB )
  33. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/database.php ( 2.48 KB )
  34. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/Env.php ( 1.67 KB )
  35. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/filesystem.php ( 0.61 KB )
  36. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/lang.php ( 0.91 KB )
  37. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/log.php ( 1.35 KB )
  38. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/middleware.php ( 0.19 KB )
  39. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/route.php ( 1.89 KB )
  40. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/session.php ( 0.57 KB )
  41. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/trace.php ( 0.34 KB )
  42. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/view.php ( 0.82 KB )
  43. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/event.php ( 0.25 KB )
  44. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Event.php ( 7.67 KB )
  45. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/service.php ( 0.13 KB )
  46. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/AppService.php ( 0.26 KB )
  47. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Service.php ( 1.64 KB )
  48. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Lang.php ( 7.35 KB )
  49. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/lang/zh-cn.php ( 13.70 KB )
  50. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/Error.php ( 3.31 KB )
  51. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/RegisterService.php ( 1.33 KB )
  52. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/services.php ( 0.14 KB )
  53. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/PaginatorService.php ( 1.52 KB )
  54. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/ValidateService.php ( 0.99 KB )
  55. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/ModelService.php ( 2.04 KB )
  56. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/Service.php ( 0.77 KB )
  57. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Middleware.php ( 6.72 KB )
  58. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/BootService.php ( 0.77 KB )
  59. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/Paginator.php ( 11.86 KB )
  60. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-validate/src/Validate.php ( 63.20 KB )
  61. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/Model.php ( 23.55 KB )
  62. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/Attribute.php ( 21.05 KB )
  63. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/AutoWriteData.php ( 4.21 KB )
  64. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/Conversion.php ( 6.44 KB )
  65. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/DbConnect.php ( 5.16 KB )
  66. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/ModelEvent.php ( 2.33 KB )
  67. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/RelationShip.php ( 28.29 KB )
  68. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/contract/Arrayable.php ( 0.09 KB )
  69. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/contract/Jsonable.php ( 0.13 KB )
  70. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/contract/Modelable.php ( 0.09 KB )
  71. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Db.php ( 2.88 KB )
  72. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/DbManager.php ( 8.52 KB )
  73. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Log.php ( 6.28 KB )
  74. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Manager.php ( 3.92 KB )
  75. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/log/src/LoggerTrait.php ( 2.69 KB )
  76. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/log/src/LoggerInterface.php ( 2.71 KB )
  77. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Cache.php ( 4.92 KB )
  78. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/simple-cache/src/CacheInterface.php ( 4.71 KB )
  79. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper/Arr.php ( 16.63 KB )
  80. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/cache/driver/File.php ( 7.84 KB )
  81. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/cache/Driver.php ( 9.03 KB )
  82. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/CacheHandlerInterface.php ( 1.99 KB )
  83. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/Request.php ( 0.09 KB )
  84. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Request.php ( 55.78 KB )
  85. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/middleware.php ( 0.25 KB )
  86. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Pipeline.php ( 2.61 KB )
  87. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/TraceDebug.php ( 3.40 KB )
  88. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/middleware/SessionInit.php ( 1.94 KB )
  89. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Session.php ( 1.80 KB )
  90. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/session/driver/File.php ( 6.27 KB )
  91. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/SessionHandlerInterface.php ( 0.87 KB )
  92. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/session/Store.php ( 7.12 KB )
  93. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Route.php ( 23.73 KB )
  94. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleName.php ( 5.75 KB )
  95. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Domain.php ( 2.53 KB )
  96. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleGroup.php ( 22.43 KB )
  97. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Rule.php ( 26.95 KB )
  98. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleItem.php ( 9.78 KB )
  99. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/route/app.php ( 1.72 KB )
  100. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/Route.php ( 4.70 KB )
  101. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/dispatch/Controller.php ( 4.74 KB )
  102. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Dispatch.php ( 10.44 KB )
  103. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/controller/Index.php ( 4.81 KB )
  104. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/BaseController.php ( 2.05 KB )
  105. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/facade/Db.php ( 0.93 KB )
  106. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/connector/Mysql.php ( 5.44 KB )
  107. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/PDOConnection.php ( 52.47 KB )
  108. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Connection.php ( 8.39 KB )
  109. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/ConnectionInterface.php ( 4.57 KB )
  110. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/builder/Mysql.php ( 16.58 KB )
  111. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Builder.php ( 24.06 KB )
  112. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/BaseBuilder.php ( 27.50 KB )
  113. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Query.php ( 15.71 KB )
  114. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/BaseQuery.php ( 45.13 KB )
  115. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/TimeFieldQuery.php ( 7.43 KB )
  116. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/AggregateQuery.php ( 3.26 KB )
  117. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ModelRelationQuery.php ( 20.07 KB )
  118. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ParamsBind.php ( 3.66 KB )
  119. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ResultOperation.php ( 7.01 KB )
  120. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/WhereQuery.php ( 19.37 KB )
  121. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/JoinAndViewQuery.php ( 7.11 KB )
  122. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/TableFieldInfo.php ( 2.63 KB )
  123. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/Transaction.php ( 2.77 KB )
  124. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/log/driver/File.php ( 5.96 KB )
  125. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/LogHandlerInterface.php ( 0.86 KB )
  126. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/log/Channel.php ( 3.89 KB )
  127. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/event/LogRecord.php ( 1.02 KB )
  128. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/Collection.php ( 16.47 KB )
  129. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/View.php ( 1.70 KB )
  130. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/View.php ( 4.39 KB )
  131. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Response.php ( 8.81 KB )
  132. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/response/View.php ( 3.29 KB )
  133. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Cookie.php ( 6.06 KB )
  134. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-view/src/Think.php ( 8.38 KB )
  135. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/TemplateHandlerInterface.php ( 1.60 KB )
  136. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/Template.php ( 46.61 KB )
  137. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/template/driver/File.php ( 2.41 KB )
  138. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/template/contract/DriverInterface.php ( 0.86 KB )
  139. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/runtime/temp/067d451b9a0c665040f3f1bdd3293d68.php ( 11.98 KB )
  140. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/Html.php ( 4.42 KB )
  1. CONNECT:[ UseTime:0.000604s ] mysql:host=127.0.0.1;port=3306;dbname=f_mffb;charset=utf8mb4
  2. SHOW FULL COLUMNS FROM `fenlei` [ RunTime:0.000788s ]
  3. SELECT * FROM `fenlei` WHERE `fid` = 0 [ RunTime:0.000293s ]
  4. SELECT * FROM `fenlei` WHERE `fid` = 63 [ RunTime:0.000276s ]
  5. SHOW FULL COLUMNS FROM `set` [ RunTime:0.000620s ]
  6. SELECT * FROM `set` [ RunTime:0.000272s ]
  7. SHOW FULL COLUMNS FROM `article` [ RunTime:0.000712s ]
  8. SELECT * FROM `article` WHERE `id` = 459033 LIMIT 1 [ RunTime:0.000531s ]
  9. UPDATE `article` SET `lasttime` = 1770680161 WHERE `id` = 459033 [ RunTime:0.010424s ]
  10. SELECT * FROM `fenlei` WHERE `id` = 65 LIMIT 1 [ RunTime:0.000274s ]
  11. SELECT * FROM `article` WHERE `id` < 459033 ORDER BY `id` DESC LIMIT 1 [ RunTime:0.000472s ]
  12. SELECT * FROM `article` WHERE `id` > 459033 ORDER BY `id` ASC LIMIT 1 [ RunTime:0.000408s ]
  13. SELECT * FROM `article` WHERE `id` < 459033 ORDER BY `id` DESC LIMIT 10 [ RunTime:0.003572s ]
  14. SELECT * FROM `article` WHERE `id` < 459033 ORDER BY `id` DESC LIMIT 10,10 [ RunTime:0.002351s ]
  15. SELECT * FROM `article` WHERE `id` < 459033 ORDER BY `id` DESC LIMIT 20,10 [ RunTime:0.001098s ]
0.092844s