在cucumber测试中模拟本地api

时间:2023-01-14 15:43:04

I am writing an app that access a local that lives on a separate path on my own server via ajax requests. However, I want to test the app with cucumber and mock out the backend. Is there something like artiface or sham_rack that would let me do this?

我正在编写一个应用程序,它可以通过ajax请求访问位于我自己服务器上独立路径上的本地用户。但是,我想用黄瓜来测试这个应用程序,并模拟出后端。有什么像洋蓟或三叶草这样的东西可以让我这么做吗?

3 个解决方案

#1


1  

I use MockJson to simulate the response: MockJson website

我使用MockJson模拟响应:MockJson网站

#2


2  

I'd recommend using VCR:

我建议使用录像机:

http://relishapp.com/myronmarston/vcr

http://relishapp.com/myronmarston/vcr

It allows you to record the requests to the external service once, and then play back the recorded responses when running your tests.

它允许您记录一次对外部服务的请求,然后在运行测试时回放记录的响应。

#3


0  

How about something like http://fakeweb.rubyforge.org/?

比如http://fakeweb.rubyforge.org/呢?

#1


1  

I use MockJson to simulate the response: MockJson website

我使用MockJson模拟响应:MockJson网站

#2


2  

I'd recommend using VCR:

我建议使用录像机:

http://relishapp.com/myronmarston/vcr

http://relishapp.com/myronmarston/vcr

It allows you to record the requests to the external service once, and then play back the recorded responses when running your tests.

它允许您记录一次对外部服务的请求,然后在运行测试时回放记录的响应。

#3


0  

How about something like http://fakeweb.rubyforge.org/?

比如http://fakeweb.rubyforge.org/呢?