开发者

How to simulate external APIs?

We call many different external APIs in our system and now I'm looking for a system I can use to simulate those APIs so we can test ours in the Staging and Development environments?

Our application is written in Ruby on Rails 3.0 but since all the API calls to and from it are over HTTP there is 开发者_如何学Cno language dependency.


VCR will record the actual input from the webservice and then replay that feedback from then on.

To simulate it completely, you can use fakeweb. You'll record output to a file and have it sent back to your application.


This something called test mocking/stubbing and is a common practice. Basically you override the response code of the API call to return data w/o actually doing the HTTP request. Just search it for more details.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜