1

I may be approaching this the wrong way, but is it possible to mock http call failures (http status of 500) by intercepting a http request for a specific endpoint?

I am trying to test a UI flow that only occurs with a 500 response. Is this possible, or should I look into alternate approaches of making a response 500?

  • On what layer you are testing? UI or API? Both will have different verification assertions. – Vishal Aggarwal Jun 20 '18 at 0:37
  • @VishalAggarwal These tests are running on the UI layer - integrating with API's that I do not own. – bmartin Jun 20 '18 at 4:21
  • Then don't verify response codes directly but assert the corresponding behavior in the UI. – Vishal Aggarwal Jun 20 '18 at 7:56
1

One alternative is to use Feature Flags.

With these, you can, at compiling time, pick blocks of code, depending on configuration.

For instance (pseudo-code):

def request_handler(request):
    #ifdef TESTING_MODE
    return HTTP(500);
    #endinf
    .... production code...

TESTING_MODE variable would be set in a kind of config.json file or during the building, with Jenkins, e.g.

Different stacks would have its own syntax and approaches, but the idea is the same.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.