suave
suave copied to clipboard
Testing story
Suave.Testing
I've noticed that using the testing library on NuGet assumes something about how you are testing.
The method:
let runWith config webParts =...
creates a http handler on a port and then when you use it together with
let reqResp ...
it disposes the SuaveTestContext. That implies that you need to a new instance using runWith for each test, i.e. it's singe use. If the test runner decides to run the tests in parallel then you need to set a port for each test.
It would perhaps be nice to have more of those assumptions specified more clearly. Perhaps as an example of how to test your Suave app in the examples folder?
Suave Testing light
On the other hand you have An Introduction To Testing Suave WebParts by @MattJOlson.
That blog post implies that you don't need to go through the trouble of having the full stack up and running. So perhaps it would make sense to have a namespace or module in the testing lib intended for use when you don't want a full http handler up and running.
Thoughts?
I make no claims that my approach is the best way to do it; it worked for me, once, in a fairly limited-scope environment. (But it did work!)
Anyway, depending on what part of the service you're testing, spinning up the full stack might be overkill.
I agree @MattJOlson