Go to file
parsonsmatt be49dc9cbc no CPP?
2018-05-23 15:36:43 -06:00
doc docs 2016-07-18 16:12:21 -03:00
example Support for servant-0.13 2018-02-09 20:26:02 +02:00
src/Servant no CPP? 2018-05-23 15:36:43 -06:00
test Support GHC-8.4.1 2018-03-23 08:13:36 +02:00
.gitignore Use CPP 2018-05-23 15:32:35 -06:00
.travis.yml Support GHC-8.4.1 2018-03-23 08:13:36 +02:00
CHANGELOG.yaml v0.0.7.2 (#51) 2018-05-10 11:32:50 -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 Use CPP 2018-05-23 15:32:35 -06:00
Setup.hs initial commit 2016-04-22 13:00:23 +02:00
stack.yaml try with older base-compat 2018-05-23 14:44:55 -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.