API testing

What is API and HTTP?

Learn about HTTP and RESTful services

HTTPRESTful services

API is the web service. You provide input, service does some calculations, and it provides some output.

Before development and during development:

  • We need to coordinate with developers, agree who will test particular part of API what what functionality will be of API
  • In the beginning tests will be empty, we just specify positive and negative scenarios for a certain feature. Think what classes and functions I need. Outline steps I will execute.
  • Create some mocks and focus or preparing test data.

Once code is ready:

  • Complete the tests, and create a CI pipeline (run all existing tests after commit of a new code)

Working plan

  1. Learn requirements
  2. Create test cases
  3. Execute tests

First steps

  • Get all endpoints, what kind of mandatory parameters service has?
  • Get examples of requests from dev team

Approach

  • Data driven
  • Workflow driven (end-to-end testing), how the data is passed though service
  • Don’t automate everything! Exploratory testing.

Test cases

  • Smoke, critical path, extended

To test

  • Validate status code, body, error message
  • Validate response schema (attributes and data types)
  • Validate data, and assert result with expected
  • Check optional and mandatory attributes, don’t put values of not mandatory attributes, don’t send values for not mandatory values. Perform the same with mandatory.
  • Send empty body in POST
  • Check non-existing attribute
  • Check for duplicating attributes
  • Check order of attributes
  • Insert empty elements
  • Insert comments or JS code

Test Automation Framework

  • Connect to database?
  • If GraphQL and REST API check the correct mapping of data. Validate the values, not only the presence of value.

GraphQL API Testing

Detailed test cases

💥The MOST comprehensive testing checklist and practices

Resources

SuperMade with Super