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
-
Integration tests-Service Consumer → Service Provider #contract-Tests - Protected Random Quote GET http://localhost:3001/api/protected/random-quote
-
Basic test syntax - pm.expect and pm.response GET https://postman-echo.com/get?foo1=bar1&foo2=bar2
-
Integration tests-Using mocks - Echo the exchange rate GET https://postman-echo.com/get?foo1={{bitcoinRate}}
-
Integration tests-Scenario - Add item to cart POST http://localhost:3002/{{memberId}}/cart
-
API tests - Functional2 DELETE https://postman-echo.com/delete
-
Integration tests-Scenario - Verify new item exists GET http://localhost:3002/items/{{itemId}}
-
Integration tests-Scenario - Delete item from cart DELETE http://localhost:3002/{{memberId}}/cart/{{itemId}}
-
Integration tests-Scenario - Verify item removed GET http://localhost:3002/{{memberId}}/cart