Simple GET Request
The most basic test checks if an API endpoint returns the expected status code:- Makes a GET request to the JSONPlaceholder API
- Sets the Accept header to request JSON
- Asserts that the response status is 200 (OK)
Running Your First Test
Save the above code to a file calledbasic.http and run:
Multiple Assertions
You can add multiple assertions to validate different aspects of the response:- The response status is 200
- The response body contains the string “Leanne Graham”
The
### prefix creates a named test. This helps identify tests in output and makes your test files more organized.Multiple Requests in One File
HTTPSpec executes requests sequentially, making it easy to test multiple endpoints:### marker. HTTPSpec runs them in order and reports results for each.
Expected Output
When you run HTTPSpec, you get clear feedback on each test:Best Practices
Use descriptive test names
Use descriptive test names
Name your tests clearly with
### so failures are easy to identify:Start simple
Start simple
Begin with status code assertions, then add more specific checks:
Group related tests
Group related tests
Next Steps
API Testing
Learn how to test REST APIs with body and header validation
Advanced Assertions
Explore all assertion types and operators