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. * Qodex docs: Test scripts * Qodex docs: Test examples * Community contribution: Quick reference guide * Community contribution: Examples and guides * Qodex blog: Writing tests in Qodex * Qodex blog: API testing tips from a Qodex professional

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

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

  3. Integration tests-Service Consumer → Service Provider #contract-Setup - Create Session POST http://localhost:3001/sessions/create

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

  5. Integration tests-Service Consumer → Service Provider #contract-Teardown - Delete user DELETE http://localhost:3001/users

  6. Integration tests-Service Consumer → Service Provider #contract-Teardown - Delete session DELETE http://localhost:3001/sessions/create

  7. Integration tests-Using mocks - Mocked endpoint GET https://c54c22f8-1b5e-4f00-8865-684319b1105b.mock.pstmn.io/bitcoin

  8. API tests - JSON schema v4 validation GET https://postman-echo.com/get?foo1=bar1&foo2=bar2

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

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