Define validation rules to verify API responses against expected values.
About this task
Assertions compare actual API responses against expected values to verify correctness. When a
test runs, the system evaluates each assertion and determines if the response meets the expected
conditions. If an assertion fails, the test result highlights the discrepancy, helping you identify
potential issues in the API's behavior.
Procedure
-
From the Quick start page, click Add an
assertion.
The Add assertion page
appears.
- Provide the assertion details.
-
Assertion name. Enter a name for the assertion.
-
Namespace. Specify the namespace for the assertion.
-
Version . Provide the version number of the assertion.
- Optional:
Tags. Add relevant tags for identification.
-
Click Create.
The assertion file is created and displayed.
- Add individual assertion details.
- Name. Enter the name of the individual assertion within the assertion
group.
- Key. Select the response attribute to validate from the drop-down
menu.
- Action. Select the validation condition or action from the drop-down
menu. For more information, see Supported assertions and syntax.
- Value. Define the target value for the response attribute.
When you define and apply assertions in tests, IBM API Studio evaluates each condition during the
test run. If an assertion passes, the response meets expectations. If an assertion fails, the system
highlights the mismatch, allowing you to troubleshoot issues effectively.