javascript - Testing REST web service client when the services don't yet exist - Stack Overflow

I have already read the posts link text and link text but these are covering the use case of building a

I have already read the posts link text and link text but these are covering the use case of building a REST service on the server and requiring a rapid client in order to test those services.

We have the opposite problem, we are building a web client that will municate to the server via REST, but the decision has been taken to let the client drive the format of the services on the server, this means the client is being implemented first and the services on the server second.

I am trying to look for a tool which would allow me to very quickly knock up REST web services, which the client could then be tested against. Effectively mocking the server.

Does anyone know of such a tool?

I have already read the posts link text and link text but these are covering the use case of building a REST service on the server and requiring a rapid client in order to test those services.

We have the opposite problem, we are building a web client that will municate to the server via REST, but the decision has been taken to let the client drive the format of the services on the server, this means the client is being implemented first and the services on the server second.

I am trying to look for a tool which would allow me to very quickly knock up REST web services, which the client could then be tested against. Effectively mocking the server.

Does anyone know of such a tool?

Share Improve this question edited May 23, 2017 at 10:32 CommunityBot 11 silver badge asked Dec 15, 2008 at 4:15 ChrisInCamboChrisInCambo 8,81515 gold badges53 silver badges64 bronze badges
Add a ment  | 

8 Answers 8

Reset to default 1

Depends on how your REST service will actually return the data. You should be able to abstract all the service calls and then mock JSON responses - randomly rotating the responses should be pretty straight forward.

The other thing you could do is put several result docs on the server (as above) and rotate them from the client by randomly altering the requested service URLs.

Charles is a multiplatform proxy written in Java that proxies browsers or whatever network clients you have.

You can assign URLs to files, or even directories, if you want, or you can record sessions to disk and play them later — we use it all the time for mocking up inplete or inaccessible (e.g., heavily firewalled) servers.

And it is a very good tool for debugging too because it allows to inspect all details of HTTP.

PS: Not affiliated with them, just a happy user.

If you are in the Microsoft world then I would take a look at the Microsoft.Http libraries that are in the WCF REST starter kit. There is a Microsoft.Http.Test project that has a lot of examples of how to stub http requests by either adding a stub stage in the HttpClient processing pipeline, or by building a dummy server on top of HttpListener.

HttpListener is a great .Net framework class that allows you to build a running web server in just a few lines of code. Along with the Microsoft.Http library you could produce a server that returns fake results pretty easily.

You can use the jQuery.fixture plugin that is a part of JavascriptMVC framework, but can be used also as standalone ponent. It provides a very strong approach for mocking the REST services that are not yet implemented by intercepting the ajax requests.

To learn more about it, please visit: http://www.javascriptmvc./docs.html#!jQuery.fixture

Enjoy :)

You could just create a result document and put it on a web server.. Then point the REST URL at the document. No matter what your input the output is always the pre-formated result.

Consider using the Facade design pattern then simply add a configuration value for a "simulation mode". You can then create the entire client with a simulation mode. Then, when the server is ready, update the Facade to work with the new server.

I've done this with several projects and it has been tremendously successful. Especially in large enterprise applications where some small service could go down, but the rest of the system should continue running. Just have the facade give a "simulate mode" warning to the user so they know the results probably aren't real.

Simple - use SoapUI from Eviware (free) to Mock your service.

It has the built in concept of a 'Mock' service where you can define an endpoint and have that enpoint respond to requests with realistic looking data. Once defined the mock service can be started and will happily sit there responding to requests from clients. You can even control it programatically and have it send back different responses depending on the request.

The online tutorial on service mocking is really good here.

It's easier if your application has a WADL or WSDL to work from, but not having these just means that you'll have to put in a little extra effort to create your initial Mock service.

I have been dealing with this same question. I have yet to find a descent tool out there to do this. I was really hoping SoapUI would pull through, but after using it extensively I have found their REST support, especially when it es to Mock REST services, quite lacking.

The best that I could think of would be to build a simple webserver and use filters to send the user to different resources depending on the url. This is fine and dandy for static responses, but what if I want the call to error out or display a little bit different response data. I want something like what SoapUI does with mock SOAP services, where you can run a script that looks at the data and dependent on the data, uses a different SOAP response. Anybody know of such a tool? More support for REST is slated in SoapUI's road map, but I'm guessing not in the near future.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744783746a4593496.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信