skeletest-0.4.0: Batteries-included, opinionated test framework
Safe HaskellNone
LanguageGHC2021

Skeletest.Internal.Spec.Tree

Synopsis

Spec interface

type Spec = SpecM () Source #

data SpecM a Source #

Instances

Instances details
Applicative SpecM Source # 
Instance details

Defined in Skeletest.Internal.Spec.Tree

Methods

pure :: a -> SpecM a #

(<*>) :: SpecM (a -> b) -> SpecM a -> SpecM b #

liftA2 :: (a -> b -> c) -> SpecM a -> SpecM b -> SpecM c #

(*>) :: SpecM a -> SpecM b -> SpecM b #

(<*) :: SpecM a -> SpecM b -> SpecM a #

Functor SpecM Source # 
Instance details

Defined in Skeletest.Internal.Spec.Tree

Methods

fmap :: (a -> b) -> SpecM a -> SpecM b #

(<$) :: a -> SpecM b -> SpecM a #

Monad SpecM Source # 
Instance details

Defined in Skeletest.Internal.Spec.Tree

Methods

(>>=) :: SpecM a -> (a -> SpecM b) -> SpecM b #

(>>) :: SpecM a -> SpecM b -> SpecM b #

return :: a -> SpecM a #

data SpecTree Source #

Instances

Instances details
HasField "runGroup" SpecRunner (TestInfo -> Text -> [SpecTree] -> IO TestExitCode) Source # 
Instance details

Defined in Skeletest.Internal.Spec

HasField "runTrees" SpecRunner (TestInfo -> [SpecTree] -> IO TestExitCode) Source # 
Instance details

Defined in Skeletest.Internal.Spec

data SpecTest Source #

Constructors

SpecTest 

Fields

  • name :: Text
     
  • markers :: [SomeMarker]

    Markers, in order from least to most recently applied.

    >>> withMarker MarkerA . withMarker MarkerB $ test ...
    

    will contain

    >>> SpecTree_Test { testMarkers = [MarkerA, MarkerB] }
    
  • action :: IO TestResult
     

Instances

Instances details
HasField "runTest" SpecRunner (TestInfo -> SpecTest -> IO TestExitCode) Source # 
Instance details

Defined in Skeletest.Internal.Spec

Entrypoint

data SpecInfo Source #

Constructors

SpecInfo 

Fields

Instances

Instances details
HasField "run" SpecRunner (SpecRegistry -> IO TestExitCode) Source # 
Instance details

Defined in Skeletest.Internal.Spec

HasField "runFile" SpecRunner (SpecInfo -> IO TestExitCode) Source # 
Instance details

Defined in Skeletest.Internal.Spec

pruneSpec :: SpecRegistry -> SpecRegistry Source #

Remove specs with no tests.

Defining a Spec

describe :: String -> Spec -> Spec Source #

The entity or concept being tested.

class MonadIO m => Testable (m :: Type -> Type) where Source #

Minimal complete definition

runTestable, context, throwFailure

Methods

runTestable :: m () -> IO TestResult Source #

Instances

Instances details
Testable IO Source # 
Instance details

Defined in Skeletest.Assertions

Testable PropertyM Source # 
Instance details

Defined in Skeletest.Prop.Internal

test :: Testable m => String -> m () -> Spec Source #

it :: String -> IO () -> Spec Source #

Define an IO-based test.

Should typically be written to be read as full sentences in traditional BDD style: https://en.wikipedia.org/wiki/Behavior-driven_development.

describe "User" $ do
  it "can be checked for equality" $ do
    user1 shouldBe user1

Modifiers

newtype MarkerXFail Source #

Constructors

MarkerXFail Text 

Instances

Instances details
Show MarkerXFail Source # 
Instance details

Defined in Skeletest.Internal.Spec.Tree

IsMarker MarkerXFail Source # 
Instance details

Defined in Skeletest.Internal.Spec.Tree

xfail :: String -> Spec -> Spec Source #

Mark the given spec as expected to fail with the given description. Fails tests if they unexpectedly pass.

Can be selected with the marker @xfail

newtype MarkerSkip Source #

Constructors

MarkerSkip Text 

Instances

Instances details
Show MarkerSkip Source # 
Instance details

Defined in Skeletest.Internal.Spec.Tree

IsMarker MarkerSkip Source # 
Instance details

Defined in Skeletest.Internal.Spec.Tree

skip :: String -> Spec -> Spec Source #

Skip all tests in the given spec with the given description.

Can be selected with the marker @skip

data MarkerFocus Source #

Constructors

MarkerFocus 

Instances

Instances details
Show MarkerFocus Source # 
Instance details

Defined in Skeletest.Internal.Spec.Tree

IsMarker MarkerFocus Source # 
Instance details

Defined in Skeletest.Internal.Spec.Tree

focus :: Spec -> Spec Source #

Warning: focus should only be used in development

If at least one test is focused, skip all unfocused tests.

This definition includes a WARNING so that CI errors if it's accidentally committed (assuming CI runs with -Wall -Werror).

Since: 0.3.4

data MarkerManual Source #

Constructors

MarkerManual 

Instances

Instances details
Show MarkerManual Source # 
Instance details

Defined in Skeletest.Internal.Spec.Tree

IsMarker MarkerManual Source # 
Instance details

Defined in Skeletest.Internal.Spec.Tree

markManual :: Spec -> Spec Source #

Mark tests as tests that should only be run when explicitly specified on the command line.

Markers

class (Show a, Typeable a) => IsMarker a where Source #

Methods

getMarkerName :: a -> String Source #

The name of the marker that can be selected with @name syntax.

Marker names must only include alphanumeric characters, hyphens, underscores, and periods.

withMarkers :: [String] -> Spec -> Spec Source #

Adds the given names as plain markers to all tests in the given spec.

See getMarkerName.

withMarker :: IsMarker a => a -> Spec -> Spec Source #

Adds the given marker to all the tests in the given spec.

Useful for selecting tests from the command line or identifying tests in hooks

Internal API

withSpecTrees :: Monad m => ([SpecTree] -> m [SpecTree]) -> Spec -> m Spec Source #

mapSpecTrees :: ((SpecTree -> SpecTree) -> [SpecTree] -> [SpecTree]) -> Spec -> Spec Source #

Map the tree with the given processing function.

To preprocess trees with pre and postprocess with post:

>>> mapSpecTrees (\go -> post . map go . pre) spec

traverseSpecTrees :: Monad m => ((SpecTree -> m SpecTree) -> [SpecTree] -> m [SpecTree]) -> Spec -> m Spec Source #

Traverse the tree with the given processing function.

To preprocess trees with pre and postprocess with post:

>>> traverseSpecTrees (\go -> post <=< mapM go <=< pre) spec