Module

Mote

Re-exports from Mote.Monad

#MoteT

newtype MoteT :: (Type -> Type) -> Type -> (Type -> Type) -> Type -> Typenewtype MoteT bracket test m a

The main MoteT / Mote monadic DSL used to describe tests and groups of tests.

After description via this DSL a Plan can be generated, that can then finally be interpreted into some target monad.

  • The bracket type represents a type of kind Type -> Type kind in which bracketing can be dealt with. This type is higher kinded as the "before" part of a bracket is expressed by a type like bracket r, so that the "after" part can consume it as r -> bracket Unit later. If bracketing is not required, setting this to Const Void is a good way to communicate that it is unused/unusable.
  • The test type represents the type of tests. The kind here is only required to be Type but will usually be something like m Unit (where m here is some monad to run the tests in, not the m of MoteT).
  • The m is an underlying monad that can be used to perform effects while constructing the test suite. This allows for tests to be generated from the filesystem, reading from a Reader-based environment, etc.

The bracket and test types are separated to allow for tests and bracketing to have different constraints and capabilities. In some cases it might be desirable to run tests with an alternative Reader, or restrict the kind of effects tests are allowed to perform compared with the bracketing code.

Instances

#Mote

type Mote :: (Type -> Type) -> Type -> Type -> Typetype Mote bracket test = MoteT bracket test Identity

A non-effectful version of MoteT. This is for cases where groups and tests can be described purely.

#test

test :: forall bracket test m. Monad m => String -> test -> MoteT bracket test m Unit

Describes a new test.

#skip

skip :: forall bracket test m a. Monad m => MoteT bracket test m a -> MoteT bracket test m a

Marks the following group(s) and/or test(s) to be skipped when generating a plan.

#planT

planT :: forall bracket test m a. Monad m => MoteT bracket test m a -> m (Plan bracket test)

Generate a Plan from a MoteT, running effects as necessary. The result of this can then be interpreted to actually run the suites and tests described in the MoteT.

#plan

plan :: forall bracket test a. Mote bracket test a -> Plan bracket test

Generate a Plan from a Mote. The result of this can then be interpreted to actually run the suites and tests described in the Mote.

#only

only :: forall bracket test m a. Monad m => MoteT bracket test m a -> MoteT bracket test m a

Marks the following group(s) and/or test(s) to be added to a plan while skipping any other siblings that are not also tagged with only.

#group

group :: forall bracket test m a. Monad m => String -> MoteT bracket test m a -> MoteT bracket test m a

Describes a new group. Groups can contain further groups or tests, or a combination of both.

#bracket

bracket :: forall bracket test m a resource. Monad m => { after :: resource -> bracket Unit, before :: bracket resource } -> MoteT bracket test m a -> MoteT bracket test m a

Specifies actions to run before and after the following group(s) and/or test(s).

The bracketing is applied to every following group or test individually; it will be repeated when each group or test is run.

Re-exports from Mote.Plan

#Plan

newtype Plan :: (Type -> Type) -> Type -> Typenewtype Plan b t

The plan for running a test suite.

#foldPlan

foldPlan :: forall b t i r. (Entry b t -> i) -> (String -> i) -> (Entry b (Plan b t) -> i) -> (Array i -> r) -> Plan b t -> r

Eliminates each PlanItem constructor and sequences actions within a Plan.

This function can be used to inspect the plan, or build derivatives of it, or to define an interpreter for the plan that will actually run the tests within.

  • The first function handles tests.
  • The second function handles skipped tests.
  • The third function handles groups of tests.
  • The fourth function deals with sequencing the resulting values from the previous handlers.

This fold only applies one layer at a time, so when building an interpreter it will need to be called recursively within the group handler.

Modules