Mimic轻量级Web服务测试桩

联合创作 · 2023-10-01

Mimic, 轻量级Web服务测试桩

开发语言:Ruby

注册一个Web请求测试桩:

Mimic.mimic.get("/some/path").returning("hello world")

使用RestClient访问该请求:

$ RestClient.get("http://www.example.com:11988/some/path") # => 200 | hello world

注册多个请求测试桩; 注意你可以用不同得方法为同一个url注册多个请求。

Mimic.mimic do
  get("/some/path").returning("Hello World", 200)
  get("/some/other/path").returning("Redirecting...", 301, {"Location" => "somewhere else"})
  post("/some/path").returning("Created!", 201)
end
浏览 3
点赞
评论
收藏
分享

手机扫一扫分享

编辑
举报
评论
图片
表情
推荐
点赞
评论
收藏
分享

手机扫一扫分享

编辑
举报