1-- | @Servant.QuickCheck@ provides utilities related to using QuickCheck over an API.
2-- Rather than specifying properties that individual handlers must satisfy,
3-- you can state properties that ought to hold true of the entire API.
5-- While the API must be described with @servant@ types, the server being
6-- tested itself need not be implemented with @servant-server@ (or indeed,
9-- /N.B./ The examples given here assume the following setup:
12-- > import Servant.QuickCheck
15-- > type API = ReqBody '[JSON] Int :> Post '[JSON] String
19module Servant.QuickCheck
22 -- * Server properties
23 -- | Functions to verify that a server meets certain properties.
27 -- > server :: Server API
28 -- > server = return . show
32 -- > test = describe "my server" $ do
34 -- > it "never throws a 500 on valid input" $ do
35 -- > withServantServer api server $ \url ->
36 -- > serverSatisfiers api url emptyPredicates never500s 100
40 -- | Functions to verify that two servers behave identically.
42 -- This can be useful when for example rewriting or refactoring an
47 -- > server :: Server API
48 -- > server = return . show
50 -- > server2 :: Server API
51 -- > server2 = const $ return "hi"
54 -- > test = describe "my new server" $ do
56 -- > it "behaves like the old one" $ do
57 -- > withServantServer api server $ \url1 ->
58 -- > withServantServer api server2 $ \url2 ->
59 -- > serversEqual api url1 url2 100
63 -- * Server benchmarking
64 -- | Functions that randomly generate and run benchmarking scripts
70 -- * Test setup helpers
71 -- | Helpers to setup and teardown @servant@ servers during tests.
75 -- | Predicates (functions with signatures @a -> Bool@) are used to filter
76 -- out QuickCheck-generated values (so as to specify that requests must
77 -- possess certain properties) and to check that the response specifies the
78 -- expected properties.
84 -- ** Predicate convenience functions
88 -- ** Useful predicates
98import Servant.QuickCheck.Internal
99import Servant.Client (BaseUrl(..), Scheme(..))
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list