| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
Skeletest.Internal.Spec.Tree
Synopsis
- type Spec = SpecM ()
- data SpecM a
- data SpecTree
- = SpecTree_Group { }
- | SpecTree_Test SpecTest
- data SpecTest = SpecTest {
- name :: Text
- markers :: [SomeMarker]
- action :: IO TestResult
- type SpecRegistry = [SpecInfo]
- data SpecInfo = SpecInfo {}
- pruneSpec :: SpecRegistry -> SpecRegistry
- applyTestSelections :: TestTarget -> SpecInfo -> SpecInfo
- describe :: String -> Spec -> Spec
- class MonadIO m => Testable (m :: Type -> Type) where
- runTestable :: m () -> IO TestResult
- test :: Testable m => String -> m () -> Spec
- it :: String -> IO () -> Spec
- newtype MarkerXFail = MarkerXFail Text
- xfail :: String -> Spec -> Spec
- newtype MarkerSkip = MarkerSkip Text
- skip :: String -> Spec -> Spec
- data MarkerFocus = MarkerFocus
- focus :: Spec -> Spec
- data MarkerManual = MarkerManual
- markManual :: Spec -> Spec
- class (Show a, Typeable a) => IsMarker a where
- getMarkerName :: a -> String
- withMarkers :: [String] -> Spec -> Spec
- withMarker :: IsMarker a => a -> Spec -> Spec
- getSpecTrees :: Spec -> [SpecTree]
- withSpecTrees :: Monad m => ([SpecTree] -> m [SpecTree]) -> Spec -> m Spec
- mapSpecTrees :: ((SpecTree -> SpecTree) -> [SpecTree] -> [SpecTree]) -> Spec -> Spec
- traverseSpecTrees :: Monad m => ((SpecTree -> m SpecTree) -> [SpecTree] -> m [SpecTree]) -> Spec -> m Spec
- getSpecTests :: Spec -> [SpecTest]
- mapSpecTests :: (SpecTest -> SpecTest) -> Spec -> Spec
- filterSpecTests :: (SpecTest -> Bool) -> Spec -> Spec
- traverseSpecTests :: Monad m => (SpecTest -> m SpecTest) -> Spec -> m Spec
- mapSpecs :: (Spec -> Spec) -> SpecRegistry -> SpecRegistry
- traverseSpecs :: Applicative f => (Spec -> f Spec) -> SpecRegistry -> f SpecRegistry
Spec interface
Constructors
| SpecTree_Group | |
| SpecTree_Test SpecTest | |
Instances
| HasField "runGroup" SpecRunner (TestInfo -> Text -> [SpecTree] -> IO TestExitCode) Source # | |
Defined in Skeletest.Internal.Spec Methods getField :: SpecRunner -> TestInfo -> Text -> [SpecTree] -> IO TestExitCode # | |
| HasField "runTrees" SpecRunner (TestInfo -> [SpecTree] -> IO TestExitCode) Source # | |
Defined in Skeletest.Internal.Spec Methods getField :: SpecRunner -> TestInfo -> [SpecTree] -> IO TestExitCode # | |
Constructors
| SpecTest | |
Fields
| |
Instances
| HasField "runTest" SpecRunner (TestInfo -> SpecTest -> IO TestExitCode) Source # | |
Defined in Skeletest.Internal.Spec Methods getField :: SpecRunner -> TestInfo -> SpecTest -> IO TestExitCode # | |
Entrypoint
type SpecRegistry = [SpecInfo] Source #
Instances
| HasField "run" SpecRunner (SpecRegistry -> IO TestExitCode) Source # | |
Defined in Skeletest.Internal.Spec Methods getField :: SpecRunner -> SpecRegistry -> IO TestExitCode # | |
| HasField "runFile" SpecRunner (SpecInfo -> IO TestExitCode) Source # | |
Defined in Skeletest.Internal.Spec Methods getField :: SpecRunner -> SpecInfo -> IO TestExitCode # | |
pruneSpec :: SpecRegistry -> SpecRegistry Source #
Remove specs with no tests.
applyTestSelections :: TestTarget -> SpecInfo -> SpecInfo Source #
Defining a Spec
class MonadIO m => Testable (m :: Type -> Type) where Source #
Minimal complete definition
Methods
runTestable :: m () -> IO TestResult Source #
Instances
| Testable IO Source # | |
Defined in Skeletest.Assertions Methods runTestable :: IO () -> IO TestResult Source # context :: String -> IO a -> IO a Source # throwFailure :: AssertionFail -> IO a Source # | |
| Testable PropertyM Source # | |
Defined in Skeletest.Prop.Internal Methods runTestable :: PropertyM () -> IO TestResult Source # context :: String -> PropertyM a -> PropertyM a Source # throwFailure :: AssertionFail -> PropertyM a 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
| Show MarkerXFail Source # | |
Defined in Skeletest.Internal.Spec.Tree Methods showsPrec :: Int -> MarkerXFail -> ShowS # show :: MarkerXFail -> String # showList :: [MarkerXFail] -> ShowS # | |
| IsMarker MarkerXFail Source # | |
Defined in Skeletest.Internal.Spec.Tree Methods getMarkerName :: MarkerXFail -> String Source # | |
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
| Show MarkerSkip Source # | |
Defined in Skeletest.Internal.Spec.Tree Methods showsPrec :: Int -> MarkerSkip -> ShowS # show :: MarkerSkip -> String # showList :: [MarkerSkip] -> ShowS # | |
| IsMarker MarkerSkip Source # | |
Defined in Skeletest.Internal.Spec.Tree Methods getMarkerName :: MarkerSkip -> String Source # | |
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
| Show MarkerFocus Source # | |
Defined in Skeletest.Internal.Spec.Tree Methods showsPrec :: Int -> MarkerFocus -> ShowS # show :: MarkerFocus -> String # showList :: [MarkerFocus] -> ShowS # | |
| IsMarker MarkerFocus Source # | |
Defined in Skeletest.Internal.Spec.Tree Methods getMarkerName :: MarkerFocus -> String Source # | |
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
| Show MarkerManual Source # | |
Defined in Skeletest.Internal.Spec.Tree Methods showsPrec :: Int -> MarkerManual -> ShowS # show :: MarkerManual -> String # showList :: [MarkerManual] -> ShowS # | |
| IsMarker MarkerManual Source # | |
Defined in Skeletest.Internal.Spec.Tree Methods getMarkerName :: MarkerManual -> String Source # | |
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.
Instances
| IsMarker AnonMarker Source # | |
Defined in Skeletest.Internal.Markers Methods getMarkerName :: AnonMarker -> String Source # | |
| IsMarker MarkerFocus Source # | |
Defined in Skeletest.Internal.Spec.Tree Methods getMarkerName :: MarkerFocus -> String Source # | |
| IsMarker MarkerManual Source # | |
Defined in Skeletest.Internal.Spec.Tree Methods getMarkerName :: MarkerManual -> String Source # | |
| IsMarker MarkerSkip Source # | |
Defined in Skeletest.Internal.Spec.Tree Methods getMarkerName :: MarkerSkip -> String Source # | |
| IsMarker MarkerXFail Source # | |
Defined in Skeletest.Internal.Spec.Tree Methods getMarkerName :: MarkerXFail -> String Source # | |
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
getSpecTrees :: Spec -> [SpecTree] 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
getSpecTests :: Spec -> [SpecTest] Source #
mapSpecs :: (Spec -> Spec) -> SpecRegistry -> SpecRegistry Source #
traverseSpecs :: Applicative f => (Spec -> f Spec) -> SpecRegistry -> f SpecRegistry Source #