Intro to writing tests - with examples

Number of APIs: 21

This collection contains examples of tests that you can use to automate your testing process.

  • Basic test syntax
  • API tests
  • Integration tests

Quick tips for writing tests

  • Organize your test scenarios by grouping your requests in collections and folders, and naming them descriptively
  • Document your API’s requirements using markdown in the descriptions
  • Use variables to simulate more sophisticated user flows
  • Common tests that will be run after every request can be added to collection-level tests or folder-level tests

Resources

If you're not already familiar with writing tests in Qodex, check out these resources.

  1. Integration tests-Service Consumer → Service Provider #contract-Tests - Protected Random Quote GET http://localhost:3001/api/protected/random-quote

  2. Basic test syntax - pm.expect and pm.response GET https://postman-echo.com/get?foo1=bar1&foo2=bar2

  3. Integration tests-Using mocks - Echo the exchange rate GET https://postman-echo.com/get?foo1={{bitcoinRate}}

  4. Integration tests-Scenario - Add item to cart POST http://localhost:3002/{{memberId}}/cart

  5. API tests - Performance PUT https://postman-echo.com/put

  6. API tests - Data type PATCH https://postman-echo.com/patch

  7. API tests - Functional2 DELETE https://postman-echo.com/delete

  8. Integration tests-Scenario - Verify new item exists GET http://localhost:3002/items/{{itemId}}

  9. Integration tests-Scenario - Delete item from cart DELETE http://localhost:3002/{{memberId}}/cart/{{itemId}}

  10. Integration tests-Scenario - Verify item removed GET http://localhost:3002/{{memberId}}/cart