#testModel Source

testModel :: forall success failure result command model m. Monad m => Monoid success => TestModelOptions m model command result failure success -> m (List (Result model command result failure success))

Test a model

#Result Source

type Result model command result failure success = { commands :: List command, initialValue :: Int, mockResults :: List result, model :: model, outcome :: Outcome failure success, realResults :: List result }

A custom Result type replacing Result from QuickCheck.

Often when doing model-based testing, it is useful to have rich information of both success and failure outcomes. QuickCheck's result is pretty limited in its reporting facilities and is best suited to simple unit tests.

#TestModelOptions Source

type TestModelOptions m model command result failure success = { commandListGenerator :: Gen (List command), commandShrinker :: (List command) -> (List (List command)), initialModelGenerator :: Gen model, mock :: model -> command -> (Tuple model result), nres :: Int, postcondition :: command -> result -> result -> Outcome failure success, seed :: Int, setup :: Int -> m Unit, sut :: command -> m result, sutInitializer :: model -> m Unit, teardown :: Int -> m Unit }

Options passed to testModel

There are a lot, and it's pretty ugly. Sorry.

  • seed ∷ seed used to seed the quickCheck generator
  • nres ∷ the number of results to generate
  • setup ∷ used to set up the SUT before testing
  • teardown ∷ used to tear down the SUT after testing
  • sutInitializer ∷ used to initialize the SUT before a test
  • initialModelGenerator ∷ QuickCheck generator used to generate the initial model that kicks off the test and is consumed by the sutInitializer
  • commandListGenerator ∷ generator for the list of commands going to the mock and SUT
  • commandShrinker ∷ a shrinker a la QuickCheck of the command list
  • mock ∷ a mock of the model
  • sut ∷ the sut
  • postcondition ∷ the postcondition to validate after each command is run, accepting the command, the mock result, and the real result

#Outcome Source

newtype Outcome a b