Automated Testing of a RESTful Web Service with Dapi

Jul 2, 2024

Automated Testing of a RESTful Web Service with Dapi

Introduction

  • Dapi: integrated suite of applications for API testing.
  • Focus: creating an automated test of a RESTful web service.

Creating a Test Project

  • Source: Swagger definition of the Pet Store API.
  • Action: Copy the definition URL from Pet Store's Swagger page.

Test Case Overview

  • Test Steps: Two requests to the service.
    1. POST Request: Adds a pet to the server.
    2. GET Request: Retrieves information on a pet from the server.

Creating a Test Case for the POST Request

  • Test Case Editor: Configure and run your test case.
  • Navigator: Browse through projects, test suites, test cases, and test steps.

Adding a Second Test Step (GET Request)

  • Select Request Test Step: Open editor to configure request and view response.
  • Request Details: Contains a JSON body describing a pet object to add to the server.
  • Response Details: Contains a JSON body representing the stored object.

Validating Responses

  • Validation Rules/Assertions: Automatically validate responses by ensuring assertions pass.
  • Creating Assertions: Example - Verify that response body contains an ID element.
    • Method: Right-click on ID element in the outline tab and create an existence assertion.

Passing Values Between Test Steps

  • Pass ID to 'GET Pet by ID' Request
    • Action: Select source of value (response of 'Add Pet' test step).
    • Outcome: Insert ID value into 'GET Pet by ID' request.

Running and Validating Test Case

  • Regression Testing: Ensure API handles requests/responses properly.
  • Test Step Status:
    • First Step: Passed (assertion passed).
    • Second Step: Unknown (no assertion applied).

Enhancing Test Cases

  • Wizard: Quickly create tests for all operations in the definition.
    • Assertions: Choose suggested ones or add your own.
  • Navigator: View multiple test cases created automatically.
  • Additional Enhancements: Add data source setup, authenticate, or create reports on test case runs.

Conclusion

  • Successfully created a simple functional REST test with two requests.
  • Encourage viewing other videos to learn more about advanced topics.

Thank you for watching!