In the help article related to APIs, we looked at the basics of applying TCD to testing the business logic (e.g. successful payment given multitude of factors, their interactions and associated rules).
In this one, let’s talk about the data as it relates to the communication between systems – using this guide by Pact as a reference (note however – these Test Case Designer methods are not limited to or specific to contract testing).
We will leverage a slightly modified setup. There are still a consumer (Order Web) and its provider (the Order API). And we will still be submitting the request for product information from Web to API, but will “enrich” the attributes a bit:
Request:
One or both factors need to be present for the successful request
Response :
(keeping in mind we care more about the structure and format compatibility than about the business logic calculations)
Some products are new and have not been evaluated and/or sold yet
Both approaches described below are viable, and the choice will depend on the specific system & testing goals, as discussed in the “Decision Points” section later.
This is similar to the model designed in the API article. We will have a TCD parameter for each eligible request and response attribute that a) varies in finite manner; b) needs to be validated.
Value expansions play the role of data specification in such models (e.g. 2/3/2022) since they would be the only element populated in the CSV or Automate export (which are typically used for this type of testing).
Each row in the Scenarios table would describe all parameterizable response attributes for a given request combination.
With data validation testing, there are usually fewer interactions/dependencies between the attributes. So, the mixed-strength setting with some 2-way on the request side and mostly 1-way on the response one is expected.
One script with “Then” line per attribute would cover all scenarios:
Side note: if there are attributes that don’t have format variations, can’t be blank and therefore wouldn’t become TCD parameters, the steps & validations for those would be hardcoded (i.e. without <> syntax) in the script.
To enable this in TCD, we will “transpose” our thinking from Approach 1. We will have a pair of parameters – “Validation Element” (the list of all non-status response attributes we need to check) and “Validation Value” (the list of all non-status response values we need to check).
Then we will constrain each Validation Element only to the relevant Value.
A single script with a single “Then” line would cover all scenarios, because the key wording is dynamically tied to the TC table:
Approach 1 – Pros:
Approach 1 – Cons:
To no surprise, the points below are the mirror reflection of the above.
Approach 2 – Pros:
Approach 2 – Cons:
Side note: “number of tests” as a metric becomes irrelevant in this comparison since the number of steps per test and the corresponding execution time/effort are too different.
Hopefully this article has demonstrated how Test Case Designer can be applied to use cases where n-way interactions are not really the priority anymore. The speed of scenario generation and the one-to-many scripting move into the spotlight, so the tool can still deliver benefits in either approach.
Extra consideration: shared TCD model can serve as another collaboration artifact between the consumer and the provider, which could allow to uncover mismatching expectations between much faster.