Service Virtualization

Expand all | Collapse all

Continuous testing/monitoring of JSON Requests

Jump to Best Answer
  • 1.  Continuous testing/monitoring of JSON Requests

    Posted 09-11-2020 11:09 AM
    Hi,

    This is a special need that we want to implement in our area. We want to set up kind of Continuous testing/monitoring for the given set of 'Request Samples' [of JSON format] which are placed in some LAN folder. We want all 'Request Samples' to be tested some specific weekday. Below is the quick approach of test that we have designed: 

    1. Pick/select a Request Sample [.JSON] from the LAN folder.
    2. Submit the Request file to a server [http://myserver:2020/sampletest/V1], which processes the request, and provides Response.
    3. Parse the server Response [.JSON] to capture the headers info [viz., status, response-code,..] which would further used to categorize the test status [PASS/FAIL], and place the responses accordingly to 'Pass', 'Fail' folders of LAN.
    4. Have to repeat the Steps 1-3 for all other Request Samples [.JSON] of LAN folder.

     However, I could make progress with Step#1, where I have developed bean shell code to iterate and read through ALL request sample files of the LAN folder. And here I'm looking for help on Step#2 and 3. Request you to share your views/thoughts on 'How to submit the JSON request to server' and 'How to parse the server Response for specific headers info'.

     Your quick help greatly appreciated. Thank you !!



  • 2.  RE: Continuous testing/monitoring of JSON Requests
    Best Answer

    Posted 09-14-2020 01:11 AM
    Hi Venkata,

    You can use "REST Step" to execute/send the request messages. Below approach could be helpful in a test case:

    1. Read the list of files from a specific location  - (you can use "Load a set of File Names" dataset or script)
    2. Once the filename is available, use the filename to read the content of it using "Read a File" step and save it in a variable 
    3. Use this variable in your rest step in content tab to send message to the server i.e. http://myserver:2020/sampletest/V1
    4. Once you get the response, 
     4.1. Use Json filters to capture different tags 
     4.2 Use Assertions to validate the status of test case
    5. Write the status of test execution (In excel or DB along with FileName)
    6.(Optional) Save the response file to a specific folder location for later references 

    Thanks.



    ------------------------------
    Regards,
    Vaibhav Jain
    Capgemini
    ------------------------------



  • 3.  RE: Continuous testing/monitoring of JSON Requests

    Posted 27 days ago
    Thank you Vaibhav, for the details. It helped me to develop the test.
    One question here..As part of Step#6 [from your response] im currently saving the server 'Response' to some LAN folder by using 'Save Property Value to File' filter. However, we want to save the given 'Response' content to two different folders 'Pass' and 'Fail' for the 'Success' and 'Error' status responses respectively. Please advise to achieve this in the test. Thanks again. !


  • 4.  RE: Continuous testing/monitoring of JSON Requests

    Posted 27 days ago
    Hi Venkata,

    Based on the results from step#4 or 5, you can have a conditional flow to write files to specific location. Example if property Status = "Pass" then go to step where you configured the folder path of PASS_Records else go to step where Error_Records is configured. At a time only one step will be invoked so this will not add any overhead to you test.

    Thanks

    ------------------------------
    Regards,
    Vaibhav Jain
    Capgemini
    ------------------------------