|
1 | 1 | # Httpspec |
2 | 2 |
|
3 | 3 | Httpspec is a tool that expands upon HTTP Files by adding assertions to them, to be used for integration tests. HTTPSpec is also intended |
4 | | -to be a test suite runner for these extended HTTP Files. More coming soon. |
| 4 | +to be a test suite runner for these extended HTTP Files. |
| 5 | + |
| 6 | +Httpspec takes in an .http (or .httpspec) file, runs those requests in sequence with optional assertions that are checked along the way. Let's take the following specfile: |
| 7 | + |
| 8 | +``` |
| 9 | +### Make a simple 200 request to HTTP Bin |
| 10 | +GET http://httpbin.org/status/200 |
| 11 | +Content-Type: application/json |
| 12 | +
|
| 13 | +### Make a simple 404 request to HTTP Bin |
| 14 | +GET http://httpbin.org/status/404 |
| 15 | +Content-Type: application/json |
| 16 | +//# status == 403 |
| 17 | +
|
| 18 | +### Make a simple 201 request to HTTP Bin |
| 19 | +GET http://httpbin.org/status/201 |
| 20 | +Content-Type: application/json |
| 21 | +``` |
| 22 | + |
| 23 | +Httpspec takes this file, executes the first request (/status/200 in this case), and since there's no assertions for this request, as long as the request succeeds, it continues on. Then, we'd run the /status/404 request but we're asserting that the status returned is a 403 -- which it is not. In this case, the request is made and we check the response against those assertions, which fail. Since these assertions fail, we do not continue to make the 201 request. |
| 24 | + |
| 25 | +The idea behind Httpspec is to allow you to specify a series of HTTP requests (with assertions) to model a sequence of test steps. For example, the first request in your file may create a user in your API which is then needed by future requests. You may then make another request, using those user credentials, to create an order for that user -- again, this is just an example. |
| 26 | + |
| 27 | +There are some gaps in this implementation at this point (these are things I plan to address): |
| 28 | + |
| 29 | +1. There is not currently a way to pipe the response from a previous request into the next request. This is limiting as you often may need an ID from a previous request to make the next request. |
| 30 | +2. Currently, HTTPSpec only takes in a single file. I intend to also support directory paths, but this hasn't been implemented yet. |
| 31 | +3. Currently, everything runs serially. The plan is to run each file in isolation against a thread pool. This will happen eventually, so if you start writing tests today, write them with this in mind (dont try to get fancy with sequencing of test files). |
| 32 | +4. Not all of the assertion types specified in the [specification](./HTTPSpec.md) are implemented yet. |
0 commit comments