How to Write Tests

1. To start with Swagger Functional Testing, click on the Functional Testing tile on the Swagger main page.

SwaggerFunctionalTesting_Screenshot_Swagger_View.png

2. Your tests library opens. Click the Create Test button.

SwaggerFunctionalTesting_Screenshot_Create_Test.png

3. Name your test, choose the method and the endpoint. Click Create Test.

SwaggerFunctionalTesting_Screenshot_Test_Details.png

4. Your test now appears in the test library. Click on it to add test steps.

SwaggerFunctionalTesting_Screenshot_Test_Library.png

5. You can choose your test step type by clicking the plus icon on the test steps list. You can also click on the big plus icon at the right bottom corner.

SwaggerFunctionalTesting_Screenshot_Test_Step.png

6. After you choose your Test Step type, fill in the details and click Save.

SwaggerFunctionalTesting_Screenshot_Test_Step_Details.png

7. You can dynamically select values in an API response and assign them to a variable to use in another API request.

SwaggerFunctionalTesting_Screenshot_Validate_Response.png

Go to Define an API request to learn more.

Tip

You can reorder test steps by dragging and dropping them. Move single or multiple steps up or down, even in and out of segments.

You can also duplicate selected steps in test cases. Duplicated steps appear right after the last selected step. If the last selected step is inside a segment, the steps are duplicated after the segment. Segments cannot be duplicated.

8. Once you complete all of the test steps, click the Run Test button at the top right corner.

9. Click View Results to find more details connected to your test run.

SwaggerFunctionalTesting_Screenshot_View_Results.png
SwaggerFunctionalTesting_Screenshot_Test_Run_Details.png

10. Go to the Test tab, to see the list of all your test cases.

How to Add Test Steps from Endpoints Created in

  1. Click the + icon to add an API in your test definition view.

    SwaggerFunctionalTesting_Screenshot_Add_API_Step.png
  2. Select Create APIs step from OpenAPI spec.

  3. Choose the APIs and endpoints from the modal and click the Add Test Steps button to proceed. You can choose the version of your endpoints.

    SwaggerFunctionalTesting_Screenshot_Add_API_Step_From_SwaggerStudio.png
  4. Selected endpoints are added as test steps to your test.

  5. If you add the step from a new parameter called baseURL is created and inserted before each endpoint path. You can update baseURL and add other variables and parameters from the test definition page above.

  6. Click Execute Request to verify the response.

  7. Enter a value and save the whole test by clicking the Save button.

How to Create Test From Swagger Explore

  1. If you decide to create a test from the entire set of API endpoints, navigate to Explore and click on Create Test Case.

  2. Select the endpoints you want to add to your test. You can choose an existing test case from the drop-down menu.

    SwaggerFunctionalTesting_Screenshot_Add_API_Step_From_Explore.png
  3. Click the Add Steps button to proceed.

  4. Test case is created. Click Save.

  5. You can now run your test case or create more test steps.

Publication date: