Follow

Modifying the API Test Maker Model

The Edit API Tests page lets you modify all of the operations that are included in your model. When you select a specific operation in the left pane, the right pane is divided into the following tabs:

  • Parameters Tab
    Lets you modify the parameters, reference values, and parameter constraints that are defined for the selected operation. 
  • Body Tab
    Lets you define the body parameter for POST, PUT, and PATCH operations. The body parameter is the data transmitted in an HTTP transaction message immediately following the headers.
  • Assertions Tab
    Lets you apply assertions that further define the pass and fail conditions for your tests.
  • Tests Tab
    Lets you create auto generated and manual tests for the selected operation. For more information about this tab, see Creating New Functional API Tests.
  • Summary Tab
    Provides a brief description of the selected operation as well as the defined parameters and response codes.

SwaggerModel.png

This page provides the following step-by-step instructions for modifying a model:

Note: We currently fully support String and Number parameter types. For these parameter types, you can do full constraint and reference value modeling, and you can create a complete set of positive, negative, and edge test cases. For all other parameter types, we support saving and changing the reference value only. For each parameter, the saved reference value is used for generating all test cases that include that parameter.

The following video provides a brief introduction to updating an API model.

Accessing a Specific Operation in Your Model

  1. Create an API model or edit an existing one.
  2. Click a resource in the left pane to view the operations under that resource.
  3. Click an operation name to view the details for that operation in the right side of the page.

Adding an Operation

The left pane lists all of the resources and operations in your model. The field at the top of this pane lets you add additional resources and operations.

  1. Select the type of operation that you want to add (GET, POST, PUT, DELETE, or PATCH).ManualModel02.png
  2. Type the resource path in the Enter resource path field.
    • Path parameters are defined as part of your resource path. They are indicated with {}. You can change reference values and constraints for path parameters in the Parameters tab, but you cannot add or remove them. By default, path parameters are created with a type of String, and the Required constraint is set to True.
      For example, /pet/{petId} creates a path parameter of petId.
    • Rather than creating query parameters one at a time in the Parameters tab, you can also include them here in your resource path.
      For example, /user/login?username=admin&password=password creates a resource of /user/login with two query parameters: username with a reference value of admin, and password with a reference value of password.
    • The base URL displays at the top of the left pane. You do not need to repeat the base URL. Just enter the relative path. For example, type /pet instead of typing http://petstore.jsonpetstore.swagger.io/pet.
  3. Click the plus (+) sign next to the field.
    The operation is added to the list of operations in your model.

Updating a Parameter Reference Value

The reference value is the default value used for your test cases. 

Note: If a reference value is not defined for a parameter, the name of the parameter displays in the Reference Value field as a place holder. These place holder values are in a lighter font and indicate that no value is defined.

  1. Click the Parameters tab for the operation that you want to update.
    ReferenceValue.png
  2. Type the new value in the Reference Value field.
    When you shift focus from this field, your changes are automatically saved.
    • If you define a reference value that complies with all of the constraints for the parameter, the Reference Value field is highlighted in green, and the value is automatically saved to the model. 
    • If you define a reference value that violates one or more constraints, the Reference Value field is highlighted in red, and the value is not saved to the model. An invalid value is passed as the reference value for a quick test, but it is not used for the generated tests, and it is not saved to the model.

Adding a Parameter

  1. Click the Parameters tab for the operation that you want to update.
  2. Click Add Parameter at the bottom of the tab.
    A new parameter row is added to your list of parameters.
  3. Type the name of the parameter in the Parameter field.
  4. Select the location of the parameter in the In field; either Query or Header.
  5. Enter the reference value in the Reference Value field.
  6. Make any changes to the constraints. The following two constraints are defined by default:
    • Type = string
    • Required = false
  7. To remove a parameter:
    1. Click Delete Parameter ParameterDeleteIcon.png in the Action column. 
      Note: You can only delete Query or Header parameters. The Delete Parameter icon does not display for Path parameters.
    2. Click OK in the Confirmation window.

Note: Path parameters are defined as part of your resource path. They are indicated with {} in the resource path. You can change reference values and constraints for path parameters in the Parameters tab, but you cannot add or remove them. By default, path parameters are created with a type of String, and the Required constraint is set to True. For example, /pet/{petId} creates a path parameter of petId.

Updating Parameter Constraints

  1. Click the Parameters tab for the operation that you want to update.
    The defined constraints for the operation are listed in the Constraints column.
  2. Click View/Edit constraints in the Action column for the parameter that you want to view or modify.
    The Add Constraints section opens.
    Constraints.png
  3. Make the desired changes to the parameter constraints.
    If you add an invalid value for a constraint, the field is highlighted in red, and your changes cannot be saved. Valid values turn the field green.
  4. Click Save.
    If the reference value that is defined for the parameter now violates the updated constraints, an additional confirmation window opens. Confirm whether you want to continue and save the constraints or cancel your changes. Saving the constraints also deletes the invalid reference value.
  5. To close the Add Constraints section, click View/Edit Constraints ConstraintEditIcon.png again.
  6. To delete all constraints:
    1. Click Delete Constraints ConstraintDeleteIcon.png  in the Action column.

    2. Click OK in the Confirmation window.
      Note: All constraints except Type are removed, and the Required constraint is set to False.

Adding a Body Parameter

The Body tab lets you define the body parameter for your request. The body parameter is the data transmitted in an HTTP transaction message immediately following the headers. Typically, you use a body parameter to define the request body and payload for POST, PUT, and PATCH requests. You can define only one body parameter for each operation. You can also specify whether the acceptance of the data that is enclosed in the body is required or not.

BodyParam.png

  1. Click the Body tab for the operation that you want to modify.
  2. Select true or false from the Required field to indicate whether your body parameter is required.
  3. Type or paste your body content in the Reference Value text box and click Save.

Adding an Assertion

In addition to parameter reference values and constraints, you can also add assertions to each operation in your model. The assertion verifies whether specific elements or key names are present in the response received by a specific test. If the specified element or elements are present, then the test is successful. If the specified elements are not present, then the test fails. You can define two sets of assertions for each operation: one set of assertions for positive tests, and one set for negative tests. Each assertion set is made up of a status code and one or more schema assertions.

Note: If you created your model by uploading a Swagger specification, default assertions are created for each operation that has defined response codes in the specification. The first response for an operation is used for the positive assertion. If the operation has a default response defined, the default response is used for the negative assertion. These default assertions include the response codes, but no other assertion elements. You can either edit the default assertion sets and add additional elements, or you can delete them and create new assertions.

 

  1. Click the Assertions tab for the operation that you want to modify.
    The Assertions tab opens and displays any assertions that are already defined for this operation.
  2. Click Add Asertion at the bottom of the tab.
    The Add Assertions window opens. This window generates a list of possible assertion elements that is based on an actual response for this operation.
    AddAssertion.png
  3. Enter the parameter values that you want to use to generate a response. The system uses the response to create a list of assertion elements. 
    For example, if you want to create a set of assertions for a negative test, enter one or more invalid parameter values.
    1. If you want to include specific header content in your request, click the Additional Headers tab. Enter the header content in the text field.
    2. If you want to include specific body content in your request, click the Body tab. Enter the body content in the Body field.
  4. Click Send to send the request.
    The response from your request displays in the Response tab. A list of possible assertion elements display in the Assertions pane on the right side of the window.
  5. Enter the response code for your assertion, if different from the automatically populated value. 
  6. Select whether this assertion set is for a positive test (response code 2XX) or a negative test (all other response codes).
  7. Select the assertion elements that you want to add to this set of assertions.
    Note: If you select multiple elements, all of the selected elements must be present in the response for your test to pass.
  8. To manually add an assertion element, type the element in the field at the bottom of the Assertions pane and click the plus (+) sign.
  9. Click Save to save your assertions for this operation.
    The Add Assertions window closes, and your assertions display in the Assertions tab.
    Assertions.png
  10. To view the elements in an assertion set, click View Assertions.
  11. To edit an assertion set:
    1. Click Edit EditIcon.png  next to the assertion set that you want to edit.
      The Edit Assertions window opens and displays your selected elements.
    2. To add additional elements, define the parameter values, authorization type, and request header as described above, and click Send.
      The response from your request displays in the Response tab. A list of possible assertion elements display in the Assertions pane on the right side of the window.
      Note: When you click Send your previous element selections are lost, and you must select the elements that you want to include.
    3. Click Save to save your assertions for this operation.
  12. To delete an assertion set:
    1. Click Delete ParameterDeleteIcon.png next to the assertion set that you want to delete.
    2. Click OK in the confirmation window.

Updating the Operation Summary

The Summary tab displays a brief description of the operation, the defined parameters, and the valid response codes for the selected operation.

Summary.png

  1. Click the Summary tab for the operation that you want to update.
  2. To update the description, enter your changes in the Description field.
    When you shift focus from this field, your changes are automatically saved.
 
Have more questions? Submit a request

0 Comments

Article is closed for comments.