We have built a library which can handle RESTful requests based on configured endpoints.
- A fluent builder is being used to create endpoint definitions (configurations). These definitions are bound to a request.
- When a request is being executed, the definition is being used to set the correct parameters, like HTTP headers, the HTTP body and so on.
- Before executing the request, there is a check if the request should be cached or retrieved from a cache, the cache requirement is also stored in the endpoint definition mentioned in point 1.
Fellow developers are worried about the testability of this setup. Because:
- The configuration is being built up using a builder, to test if the configuration is set correctly, the HTTP requests which are the result of the configured endpoint need to be validated (are the header settings and so on being translated/passed correctly).The configuration resides in another library and is made not public, since it is not being accessed from the library from which the tests are running.
- The caching configuration needs to be tested, because my fellow developers want to be sure the right things are being cached according to their configuration.
These are all valid concerns, so how to test the configuration in combination with with the builder?
My option would be to mock all dependencies and make a bunch of unit tests.
actual = builder.AddThing(); Assert actual.Thing == expected