【发布时间】:2019-10-04 09:02:51
【问题描述】:
我正在通过 https://flutter.dev/docs/cookbook/testing/unit/mocking 指南学习在 Flutter 中使用 Mockito 模拟依赖项。
我不明白下面一行:
when(client.get('https://jsonplaceholder.typicode.com/posts/1'))
.thenAnswer((_) async => http.Response('{"title": "Test"}', 200));
(_) {} 中的下划线符号到底有什么作用?据我所知,() 用于传递需要在{} 正文中使用的参数。在编写_ 时,我们究竟传递给函数的是什么?
【问题讨论】:
-
是的,你可能是对的。试图自己找到它,但看起来我失败了。感谢您的回答。
标签: testing flutter dart mockito