【发布时间】:2020-02-04 05:55:42
【问题描述】:
我正在寻找在testthat 框架内模拟rest API 响应的最简单方法。
用法示例与此类似:
with_mock_api(
request,
response,
{
call_to_function_with_api_call()
# expectations check
}
)
因此,无需调用真正的 API 即可通过测试。
-
request是指将在 api 包装函数内部完成的 http 请求的定义; -
response指的是为了模拟而缓存的响应对象。
【问题讨论】:
-
例如,
request和response是什么?
标签: r api http mocking testthat