servant-swagger
servant-swagger copied to clipboard
Remove testing dependencies from library dependencies
Currently when installing servant-swagger it also pulls in QuickCheck and hspec. Are there any plans to remove this, or make it configurable via a flag?
Servant.Swagger.Test is an experimental but very useful module. It does drag some heavy dependencies like QuickCheck and hspec with it, but since it is just one module with virtually one function we have decided to leave it in servant-swagger. Also I guess most (some?) servant-swagger users use QuickCheck and hspec anyway.
A better alternative would be to create a separate servant-swagger-hspec package or something like that. The main reason we didn't split a separate package was because no one complained :)
Another reason was that I wanted to find a perfect solution and first move type-level stuff needed for tests to servant as its very general and might be useful for other means (e.g. servant-docs uses similar type families). See https://github.com/haskell-servant/servant/pull/345 for more details and discussion.
For now we could add a Cabal flag if these extra dependencies are uncomfortable for you.
Wow Servant.Swagger.Test is cool! In general I use both hspec and HTF, but current project is using HTF. It would be cool to make Servant.Swagger.Test testing-framework independent, maybe one could abstract over the "property to unit test"-function? For HTF it would be qcAssertion :: QCAssertion t => t -> Assertion (from http://hackage.haskell.org/package/HTF-0.13.1.0/docs/Test-Framework-QuickCheckWrapper.html), for hspec it's prop :: (?loc :: CallStack, Testable prop) => String -> prop -> Spec. So essentially validateEveryToJSON would need a type signature like:
validateEveryToJSON
:: (_, QCAssertion p)
=> proxy api
-> (p -> spec)
-> spec
I have not tried it out, but this should work?
Apart from that a Cabal flag would be great for short term, I like to keep my dependencies clear of another testing framework as it adds build complexity and things that can go wrong.
I am not sure we'll be able to create a universal validateEveryToJSON.
Actually there's just once piece of code that is hspec-specific: props function which is used directly in validateEveryToJSON. props implementation depends only on hspec and QuickCheck (and some type-level functions defined, but not specific to servant-swagger).
I think rather than making an all-fit solution we should move this function to hspec and write a similar one for every other testing framework.
Hi, Servant-swagger will be moved into the main Servant repo (see : https://github.com/haskell-servant/servant/pull/1475) If this issue is still relevant, would it be possible for you to summit it there? : https://github.com/haskell-servant/servant/issues
Thanks in advance!