views:

54

answers:

3

Our first ASP.Net MVC/jQuery product is about to go to QA, and we're looking for a way for our QA guys to easily be able to simulate bad Ajax requests (without modifying the application code).

A typical integration/UI test plan might be:

  1. Load page, click button "DoStuff"
  2. "DoStuff" fails
  3. Attempt button "DoStuff" again
  4. "DoStuff" succeeds
  5. Verify application state

This is a simple test case - there will be cases with multiple failures and successes interspersed. Aside from "unplug your network cable" I'm looking for an easy way for our guys to simulate intermittent bad server responses.

I'm open to any ideas so I won't go into too many details about our application setup or dependencies. How have you handled this?

+1  A: 

You could find or create a proxy, which the testers' requests would go through. This proxy would return precise results (for specific error text), or it would pass the request through to the actual server.

John Fisher
A: 

A way that might require less complex sysadmin'ing would be to build and use a different version of jQuery in staging. Hopefully that should be a pretty simple config change.

Break into the $.ajax function declaration and modify that to fail when you need it to. You could even have jQuery inject a button that floats on your page that will 'kill' the server or make it give weird responses, simply by returning handcrafted responses instead of actually making a web request.

Clint Tseng
+1  A: 

Use Fiddler and it's "Autoresponder" mechanism to return canned failure/special responses to the required URL requests.

http://www.fiddler2.com/Fiddler2/help/AutoResponder.asp

Chris