Go to file
Julian Arni 66ce50993f Unbias generation of requests. (#19)
* Unbias generation of requests:

     ...so that each endpoint is picked with the same frequency.

     Also, include a test for unbiased generation that measures mean and variance of results.
2017-10-14 07:53:04 -07:00
doc docs 2016-07-18 16:12:21 -03:00
src/Servant Unbias generation of requests. (#19) 2017-10-14 07:53:04 -07:00
test Unbias generation of requests. (#19) 2017-10-14 07:53:04 -07:00
.gitignore Add predicate getsHaveLastModifiedHeader. 2016-10-03 15:39:46 +02:00
.travis.yml Switch CI to stack 2017-03-10 15:53:26 -06:00
CHANGELOG.yaml Bump version 2017-03-11 09:36:16 -06:00
LICENSE initial commit 2016-04-22 13:00:23 +02:00
README.md Add readme 2016-04-26 13:43:52 +02:00
servant-quickcheck.cabal Bump version 2017-03-11 09:36:16 -06:00
Setup.hs initial commit 2016-04-22 13:00:23 +02:00
stack-lts-6.yaml Switch CI to stack 2017-03-10 15:53:26 -06:00
stack-lts-7.yaml Switch CI to stack 2017-03-10 15:53:26 -06:00
stack.yaml upper bound for hspec 2017-03-10 17:29:08 -06:00

servant-quickcheck

servant-quickcheck provides tools to test properties across entire APIs. Rather than writing the same tests for each endpoint, with servant-quickcheck you can simply specify properties every endpoint must meet once and for all. For example:

followsBestPractices :: Spec
followsBestPractices = describe "my API" $ do

  it "follows best practices" $ do
    withServantServer myAPI myServer $ \burl ->
      serverSatisfies api burl stdArgs
           ( not500
         <%> onlyJsonObjects
         <%> getsHaveCacheControlHeader
         <%> headsHaveCacheControlHeader
         <%> mempty)

Additionally, servant-quickcheck provides a serversEqual function that generates arbitrary requests (that conform to the description of an API) and tests that two servers respond identically to them. This can be useful when refactoring or rewriting an API that should not change.