Dart 在模拟类中将方法签名与未知参数匹配

Dart 在模拟类中将方法签名与未知参数匹配,dart,mockito,flutter-test,Dart,Mockito,Flutter Test,我有这个方法: Future<Either<Failure, WorkEntity>> updateWorkEntity({int id, String title, TimeType timeType, int times, DateTime executed}) 我可以在测试中控制id,但日期时间。现在我当然不能。我在测试中尝试了以下内容: when(repository.updateWorkEntity(id: expected.id, executed: any

我有这个方法:

Future<Either<Failure, WorkEntity>> updateWorkEntity({int id, String title, TimeType timeType, int times, DateTime executed})
我可以在测试中控制id,但日期时间。现在我当然不能。我在测试中尝试了以下内容:

when(repository.updateWorkEntity(id: expected.id, executed: any)).thenAnswer((_) async => Right(expected));
通过使用DateTime.now中的any使我的模拟返回测试的对象,但我得到以下错误:

无效参数:任何参数匹配器在外部使用 方法通过when存根或通过verify或 未填充。这是无效的,并且会导致在操作过程中出现不良行为 下一个存根或验证

所以我想我不能在这里使用任何参数,但是当我不控制其中一个输入参数时,如何让我的mock返回一个对象呢

多谢各位 瑟伦

使用executed:anyNamed'executed'代替executed:any

when(repository.updateWorkEntity(id: expected.id, executed: any)).thenAnswer((_) async => Right(expected));