Enter sub_total in the Expected Name cell. Explanation: JSON data is expressed as a collection of name/value pairs. The sub_total is the name of the target element that we want to test. We are telling the software that we want to run a test against the sub_total element found in the API response. Webtesting.io allows testers to confirm exact matches for name/value combinations found in the API response.
Enter 44.38 in the Expected Value cell. Explanation: We are informing the software that we expect the sub_total element to have a value of 44.38.
Click on the Run Tests button found in the Webtesting.io Excel Tab.
Behind the Scenes: You might be wondering how does Webtesting.io make API calls using only Microsoft Excel. Webtesting.io uses Excel VBA (Visual Basic for Applications) to invoke the Microsoft.XMLHTTP (Windows COM library) to call external Web URLs from the PC without using a Web browser. Here is the Webtesting.io code snippet that makes the actual API request:
Set oXMLHTTP = CreateObject("MSXML2.XMLHTTP") oXMLHTTP.Open HTTPVerb, TestURL, False If HTTPVerb = "GET" Then oXMLHTTP.Send Else oXMLHTTP.setRequestHeader "Content-Type", "application/json; charset=utf-8" oXMLHTTP.Send Trim(JSONInputValues) End If 'Wait for request to finish Do While oXMLHTTP.readyState <> 4 DoEvents Loop response = oXMLHTTP.responseText
Now let's review the results: The Actual Value cell contains the value 44.38. Explanation: Webtesting.io submitted a JSON request to the target API URL using a HTTP POST, and automatically parsed the 44.38 from the sub_total name/value pair.
The Pass/Fail cell contains the value PASS since the Expected Value cell equals the Actual Value cell. Explanation: Webtesting.io performs a comparison test to confirm whether the expected element value matches the actual element returned in the API Response.
The Last Ran cell displays the automated test's completion date and time information. Explanation: Each test will contain the last ran timestamp, which will visually remind the tester the last time we invoked a test.
The Actual Response From API cell should contain the actual JSON response from the exchange rates API. Explanation: This is a very helpful utility that displays the actual (raw) JSON response from the server. At times, you may find it useful to just quickly scan the raw data from the server.
The Actual Response Time contains the actual API response time in seconds (broken down in milliseconds). Explanation: Another useful nugget. This provides the round-trip time (in seconds) of the HTTP Request and Response.
Congratulations, you have successfully created an automated test with Webtesting.io!
Reviewing Test Metrics
Test metrics help measure the API operations' data consistency over a long period of time. Webtesting.io automatically prepares and reports the test summary metrics for each test life cycle.
Click on the Metrics Tab to review the test summary metrics.
The test summary metrics for this tutorial would look like the following:
Webtesting.io JSON Web Services Automated Testing solution is a useful test automation platform to help your teams with converting manual API tests to automated API tests. Webtesting.io was designed to resemble standard Microsoft Excel test plans, and this should help with reducing the learning curve usually associated with managing automated API test suites.
This article demonstrated how to create your first automated test with Webtesting.io. Hopefully, this tutorial provided you ideas how to create automated tests for your API-based solutions.