expath / expath-cg

Repository for the W3C EXPath Community Group.
15 stars 6 forks source link

HTTP Client 2.0 tests #96

Open adamretter opened 6 years ago

adamretter commented 6 years ago

We need a test suite for HTTP Client 2.0.

For example, at the moment I want to make sure we can handle the various XDM <-> HTTP JSON request/responses that we want, e.g. sending null etc.

I think we should specify it using the same grammar as https://github.com/w3c/qt3tests. AFAIK the following processors already support that:

  1. BaseX
  2. eXist-db
  3. Saxon

We should be able to easily add something to the environment of the qt3tests grammar to define/mock a simple HTTP response from the server. I would be happy to take on this task if others are in agreement, and will contribute tests too.

ChristianGruen commented 6 years ago

Great initiative! I’ll definitely add some test cases once it’s available.

In the unit tests of BaseX, we defined a FakeHttpConnection class. It’s fairly restricted, though. We could also send requests to http://httpbin.org or similar sites.

I’m looking forward to your approach.

fgeorges commented 6 years ago

From experience, the only way to test a HTTP Client is to define a HTTP Server that returns specific informations based on the URL and maybe other bits from the request.

In the test grammar, that would probably be an extension of the environments (now that's the bit providing the accessible documents, schemas, etc.) Or any configuration that would tell a piece of software acting as a HTTP Server how to respond to specific requests.

I guess there is a bit of development there :-)