Mocking local api in cucumber tests - ajax

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?

I'd recommend using 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.

I use MockJson to simulate the response:
MockJson website

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

Related

Test with postman or django-rest-framework test

i have a doubt about the tests in drf, did you use the test drf or postman?
or maybe you do both because in postman you create the documentation and and you can do a constant monitoring, what thing do you recommend me?
Use postman or other tool to check how your api is working and then make the tests. Tests are always good as if you change a code related to certain test you can immediately perform the test and check how it behaves.

What is Wiremock and can I use it to test my Rest API in Spring?

I created a REST API with Spring and want to test it. I saw WireMock but I dont really know how this library can help me. Can I use it to test my Rest API or ist it to mock another API my API uses, so that I can ensure that a mistake is coming from my Service?
What exactly do you mean by "want to test it"? How would you be "testing" your API? What would a pass/failure look like?
WireMock is a mock server service. It acts as an API that can feed in responses that you have defined (or even proxy an existing API and feed in responses it gets from there.) I usually use it in place of an unreliable API, to act as the back end for the app that I am using.
If you are looking for a library that you can use to ping your API, I've had success using REST-Assured. If you are looking for a program you can use to ping your API, Postman is my app of choice.

Analyzing POST request PhoneGap

I am making an app using PhoneGap and I am sending a POST request to a web service. Now I need to analyze the request that is being sent. What tool should I use to do that - Wireshark ?
I'm using a Mac.
An easy way to see what the post looks like is to post it to something like http://requestb.in/. That way you can test it from your app itself. Bascially change where your posting to, to the post bin you create.
Wire shark can do that but its does lot more than monitoring HTTP based requests.
Try using Fiddler for that.
http://www.fiddler2.com/fiddler2/version.asp

LoadTest in Windows Based application

I would like to do load testing in windows based application for a webservice. I will be calling a WCF Service from Windows Application which in turn calls the webservice to retrieve the results. It will accept input xml and outputs response xml.
How can I do load testing by using for loops in an asynchronous way. I don't want to use any load testing tools.
The Client reports that the "Record does not exist" is coming sometimes. But for me it is working fine. I would like to reproduce the result.
Currently I am sequentially writing the response xml to a text file. I would like to need this as asynchronous.
UPDATE:
I want to switch over from windows based application to web based application to do load test with Ajax. I would like to know how to write the Ajax code for input xml and get response xml in the form of text files
Make sure your WCF service supports multiple threads.
Generate proxy with asynchronous methods.
Spawn a lot of Begin[YourMethodName] function calls on your proxy object.

Testing a web API using RSpec and VCR

I'm writing an API wrapper as a gem, and I want to test API responses using RSpec.
The problem with this is that all API requests are made using GET, and contain an API key in the url:
e.g. game/metadata/{api_key}
This presents problems for testing, as I don't want to keep the API key in the git repository history. Is there any way I can do these spec tests, preferably with RSpec/VCR, and not store the API key in version control?
I've tried using environment variables, but VCR still stores the entire request, not just the response body.
VCR has a configuration option specifically for cases like these:
VCR.configure do |c|
c.filter_sensitive_data("<API_KEY>") { MyAPIClient.api_key }
end
See https://www.relishapp.com/myronmarston/vcr/docs/configuration/filter-sensitive-data for a larger example.

Resources