-
-
Notifications
You must be signed in to change notification settings - Fork 242
Description
Description
I would like httpexpect check to actually fail and halt the whole test execution if any of them are violated.
Let's consider the following example:
authorization := tester.POST("/oauth/callback/").
WithJSON(payload).
Expect().
Status(200).
JSON().
Object()I read this snippet like this:
- I send a POST request with
payloadto the/oauth/callback/ - I expect, so it must be true before moving on, that the response status is 200 and the response body is JSON
Expected Behaviour
When expectations fail (e.g. the response is not a plain text or status is 412, let's say), I would expect the whole test to fail right there.
Actual Behaviour
httpexpect says that the expectation is failed in the logs, but the test is keep running leading to issues like empty ID of the authorization, let's say, and potential violation of other downstream checks and requests.
The current workaround is to guard the code with additional require.* statements but bloats the test:
require.NotEmpty(t, authorization.Value("id").String().Raw())Hence, httpexpect already knows about our expectations, would not it be nice to eliminate that redundant code and fail early as a part of the httpexpect checks?