How to Improve Testing with Contract Testing and Schema Validation
Grocery shopping is one of the few things people share in common. Whether it is going to your local fruit and produce market, or the large-scale warehouses the process is fairly linear. It begins by identifying needs and what is missing, then creating a list, ending with purchases that are coordinated with the previously created list. Sounds simple enough, but the issues can compound when the list of groceries does not match the actual groceries purchased leaving one without milk for a week, but double the eggs.
A similar process occurs within API contract testing. In essence, there is an API call that is to transfer some data from the server to the client. The fundamentals of contract testing state that both the client side and the server side create a contract, or for the sake of example a grocery list. In doing so at the end of the given transaction or data transfer process both the client and server sides of the API call have comparable grocery lists. In case of any missing grocery items, or this case, required API data, the issue can be quickly identified on the server or the client side. In this week’s Feature, Friday Brett and Suraj will talk about Schema Validation a unique Qyrus feature built into Qyrus’ API testing which gives you an early indication of contract issues.
Tell us more about Schema Validation offered by Qyrus and its use cases.
Suraj: Schema validation allows users to test the format of a given API response. In essence, if there are a range of required responses, a certain set order to those responses, or any general the format or structuring to a given API response, the desired Schema can be uploaded and then tested concerning the schema which comes from the API response.
Brett: Exactly, it’s a unique form of contract testing. Rather than gathering contracts from both the client and server-side upon execution and then comparing them, we are simply allowing testers to take an already finalized schema, upload it to the Qyrus platform, and ensure that the API call is responding per that schema. In doing so you are constantly testing the server-side response for structure, and content, ensuring that when an API is called and thus data is transferred, the data structure coming in from the server is correct by format and content.
What is Schema Validation’s overall impact on the testing process?
Schema validation holds an interesting impact on the testing process. Built into the functional API testing service, schema validation is the highest level of functional testing. In essence, testing that the API response is standard to a given data structure, includes all data requirements, and fits the desired schema. Before adding any assertions across individual portions of the API response, performing a holistic check or schema validation can provide a bird’s eye view of the response patterns and ensure from a high level that no part of the API response goes against the desired structure.
Exactly, as a high-level check, this saves both time and resources, but furthermore, it denotes similar insight as to contract testing. In this case, if the schema validation fails then a server-side error can be noted. In essence, this is a clear indicator of where exactly an API response fails to meet the schema criteria, allowing for an easy path to troubleshooting and understanding exactly where this data transfer process is failing. Which API call or within a given API call which portion of the schema has been violated pointing to the corrupt, mislabeled, or incorrect data response from the API.
How might Schema Validation help testers, developers, and business technologists. What value can this feature bring?
We often see testers utilizing this feature the most as they are typically the ones responsible for backend and API testing. It truly simplifies the API testing process for testers as the alternative is having to run either standalone contract tests, or add assertions across every portion of the API response. Now with individual contract testing requiring a large overhead and resource requirement, and excessive assertions can weigh down test scripts causing delays, latency, and entirely disregarding best practices. Instead of having to do either of those testers can now simply identify the desired schema, utilizing a built-in schema extractor, paste the schema into the script now testing the structure, response types, and overall format of the API response.
Developers can also utilize the feature to ensure APIs are built properly and responding with consistent data and formatting during development. Regardless of whether applications are in beta, fully developed, or features are being tested, running schema validation provides a high-level understanding of data types and formats ultimately validating application functionality.
Though it can be considered out of scope for business analysts to do back-end API testing, let alone contract testing, schema validation builds the bridge that enables business analysts to dive into the back-end testing process. Primarily with a built-in Schema generator, the building of these tests is a simple copy-and-paste functionality. Furthermore, built into a low code, no code solution it is simple to both visualize the test script and identify inconsistencies, without a dense background in coding languages, backend testing, or development.
Does the same or similar functionality exist without Qyrus, and how do competitors address similar problems?
Contract testing is readily available throughout the testing and quality assurance space. Furthermore, the need for contract testing has never been more imminent. That being said schema validation is more of a unique feature set. Taking the overhead out of required contract creation and validation across the server and client side, allowing you to simply insert the proper schema ahead of time and test it against the API response already within your functional script optimizes script building while yielding the same results as a contract test.
Exactly, no need to create the live contract from the server side, then do the same from the client side, then go so far as to compare both contracts for validity takes resources, and time, and slows down the test building and execution process. Schema validation with Qyrus is a subset of functional testing. Place schema validation within functional testing assertions across the API header, body, and JSON path.
How do you see Schema Validation impacting day-to-day operations across organizations?
Schema validation is a high-impact solution that provides a high-level view of the API response body. This level of validation regarding the structure and data format provides great insight into the entire API response and data transfer process. Being able to get this level of insight within functional testing also simplifies the test-building process.
Furthermore, providing a good insight in terms of API formatting, and proper API data transfer, while validating the proper schema to an actual API response optimizes the test execution process as well. Taking what would be a three-part process in contract testing and yielding similar API information while only doing a single comparison decreases test execution times and makes the entire API testing process significantly more efficient.
Grocery shopping and contract testing require a great deal of understanding. In this case, where contract testing would require a grocery list from home, another from the store, and waiting until after the groceries have been purchased to compare, Qyrus’ schema validation simply asks for a single, comprehensive shopping list, doing a single comparison during checkout. Streamlining contract testing, providing the same data and reporting, while simplifying the test building process, Qyrus’ schema validation capabilities provide a unique solution to an existing requirement. Join us next week as we continue to dive into unique features and functionalities of Qyrus that redefine testing and quality assurance.