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-Scenario - Verify new item exists GET http://localhost:3002/items/{{itemId}}

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

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

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

  5. Integration tests-Service Consumer → Service Provider #contract-Setup - Create User POST http://localhost:3001/users

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

  7. API tests - SQL injection security check POST https://postman-echo.com/post

  8. Integration tests-Using variables - Bitcoin exchange rate GET https://api.coindesk.com/v1/bpi/currentprice.json

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

  10. Integration tests-Scenario - Fetch a list of items GET http://localhost:3002/items