0

i have a question about what is mock ajax calls to a service endpoint to load and save the JSON Structure. I have a html+ javascript file which act as a quiz maker, user can enter question and the question will be store into a javascript array of JSON object, so what does it mean by mock Ajax call to a service endpoint

user1968057
  • 69
  • 2
  • 11

1 Answers1

1

Usually "mocking" something means not actually making a call to the service, but rather having some alternate data provider that provides equivalent data. This allows for testing without service dependencies.

So for example say you are testing your AJAX code and don't have access to a service. Perhaps, you just have some static data which can be used to provide the data that is to be worked with, and you have some means for the code to know that it is being run in testing mode so that it pulls that data from this static source rather than a service.

This is a widely used concept in unit testing.

Mike Brant
  • 70,514
  • 10
  • 99
  • 103
  • so i am testing if i can pull the data using ajax? – user1968057 Jul 31 '13 at 00:27
  • @user1968057 I don't know the exact context in which this term has been presented to you, but actually you likely would NOT be testing your ability to retrieve the data using AJAX. That would be integration testing. Mocking would typically be used for testing the logic that works against the data provided (i.e. how you form your request, what do you do with the returned data, etc.)and allow you to isolate your testing of that code without consideration to how the real-world service is behaving. – Mike Brant Jul 31 '13 at 00:33