httpexpect
httpexpect copied to clipboard
Create unit test for AssertionContext.Request and Response
Add a test to expect_test.go that verifies that:
- AssertionContext.Request points to correct request
- AssertionContext.Response points to correct response
When:
- request reports failure (only AssertionContext.Request is set in this case)
- response reports failure
- child object of response reports failure (e.g. Response.Body)
For example, if you write this code:
req := e.GET("/test")
resp := req.Expect()
body := resp.Body()
body.IsEqual(...)
Then AssertionContext.Request should be set to req and AssertionContext.Response should be set to resp when req, resp, or body reports failure.
To inspect AssertionContext fields, the test should use a custom implementation of AssertionHandler. Then the test should imitate failure, and request, response, or body will invoke AssertionHandler.Failure and pass AssertionContext to it. Here is the point where the test can inspect context.
Hey there! I can take this.
Thanks!
@aliziyacevik Hi, do you still have plans on the issue?
Yes, thanks for the reply :)
Hi @gavv, can I work on this?
hi @gavv is the issue still there? Can i work on this?