CTAL-TAE · Question #152
An API's response to a request made to the corresponding endpoint should return some specific data about a payment transaction in JSON format. In particular, your goal is to write the test…
The correct answer is A. Specify the schema for the expected response data (properties, data types, and formats) and. The most effective and concise way to validate that the API response contains the required properties with the correct data types and formats is to define a JSON schema for the expected response and validate the actual response against it. This avoids repetitive assertions or…
Question
An API’s response to a request made to the corresponding endpoint should return some specific data about a payment transaction in JSON format. In particular, your goal is to write the test automation code, keeping it as short as possible, aimed at determining whether that response includes certain properties (“transaction_id”, “amount”, “status”, “timestamp”) with the data types and formats expected. Assuming that the TAF provides all the necessary support to validate the specified API response, how would you BEST achieve your goal?
Options
- ASpecify the schema for the expected response data (properties, data types, and formats) and
- BWrite a single assertion for each property to check whether the data types and formats for that
- CUse an artificial intelligence algorithm based on machine learning and image recognition to
- DWrite custom code that parses the actual response data and checks whether the extracted
How the community answered
(29 responses)- A83% (24)
- B3% (1)
- C10% (3)
- D3% (1)
Explanation
The most effective and concise way to validate that the API response contains the required properties with the correct data types and formats is to define a JSON schema for the expected response and validate the actual response against it. This avoids repetitive assertions or custom parsing, keeping the test automation code short and maintainable.
Topics
Community Discussion
No community discussion yet for this question.