Using cornichon for functional tests without a full http stack
Closed this issue · 2 comments
This framework and DSL are super impressive. I'm very interested in using it. One thing I haven't figured out is how I can use it to test a scala-play application without actually running the play application as a web server.
I had imagined that under-the-covers there was some app
object to which the various DSL HTTP methods were dispatched. I imagined that the default implementation of this App
interface was RealHTTPApp
but that framework specific variants would also exist.
Looking through the source code a bit, it looks like I might be able to replace the implementations of get, post, etc; but there doesn't seem to be an opinionated or framework specific approach.
Any guidance would be appreciated.
TBH I had thought that
When I get("foo/bar")
had a signature like ...
def get(resourcePath: String)(implicit app: App)
Hi @caldwecr,
Thank you for the kind words regarding the DSL.
Cornichon was designed specifically for black box testing of remote system so what you describe does not really fit the current architecture.
But as you pointed out, it is somehow possible to achieve something close to it by replacing the implementations of GET
, POST
etc to maybe interact directly with a Play! controller/route.
You could in theory achieve this by returning your special client instance here which is then injected in the actual HttpService
there.
The current design is not super nice maybe the whole thing can be improved somehow 😺
Not sure how the implicit App
would work, maybe you could describe what you have in mind?
closing due to inactivity