httpexpect icon indicating copy to clipboard operation
httpexpect copied to clipboard

Create unit test for AssertionContext.Request and Response

Open gavv opened this issue 2 years ago • 6 comments

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.

gavv avatar Feb 02 '23 09:02 gavv

Hey there! I can take this.

aliziyacevik avatar Apr 05 '23 10:04 aliziyacevik

Thanks!

gavv avatar Apr 06 '23 15:04 gavv

@aliziyacevik Hi, do you still have plans on the issue?

gavv avatar Oct 01 '23 07:10 gavv

Yes, thanks for the reply :)

aliziyacevik avatar Oct 02 '23 09:10 aliziyacevik

Hi @gavv, can I work on this?

tomaszwysocki avatar Dec 13 '23 04:12 tomaszwysocki

hi @gavv is the issue still there? Can i work on this?

Arundas666 avatar Feb 12 '24 11:02 Arundas666