Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
This module defines the IsTest
class and the different instances for it.
Synopsis
- class IsTest e where
- type Arg1 e
- type Arg2 e
- runTest :: e -> TestRunSettings -> ProgressReporter -> ((Arg1 e -> Arg2 e -> IO ()) -> IO ()) -> IO TestRunResult
- runPureTestWithArg :: (outerArgs -> innerArg -> Bool) -> TestRunSettings -> ProgressReporter -> ((outerArgs -> innerArg -> IO ()) -> IO ()) -> IO TestRunResult
- applyWrapper2 :: forall r outerArgs innerArg. ((outerArgs -> innerArg -> IO ()) -> IO ()) -> (outerArgs -> innerArg -> IO r) -> IO (Either SomeException r)
- runIOTestWithArg :: (outerArgs -> innerArg -> IO ()) -> TestRunSettings -> ProgressReporter -> ((outerArgs -> innerArg -> IO ()) -> IO ()) -> IO TestRunResult
- makeQuickCheckArgs :: TestRunSettings -> Args
- runPropertyTestWithArg :: forall outerArgs innerArg. (outerArgs -> innerArg -> Property) -> TestRunSettings -> ProgressReporter -> ((outerArgs -> innerArg -> IO ()) -> IO ()) -> IO TestRunResult
- aroundProperty :: ((a -> b -> IO ()) -> IO ()) -> (a -> b -> Property) -> Property
- aroundProp :: ((a -> b -> IO ()) -> IO ()) -> (a -> b -> Prop) -> Prop
- aroundRose :: ((a -> b -> IO ()) -> IO ()) -> (a -> b -> Rose Result) -> Rose Result
- data GoldenTest a = GoldenTest {
- goldenTestRead :: IO (Maybe a)
- goldenTestProduce :: IO a
- goldenTestWrite :: a -> IO ()
- goldenTestCompare :: a -> a -> Maybe Assertion
- runGoldenTestWithArg :: (outerArgs -> innerArg -> IO (GoldenTest a)) -> TestRunSettings -> ProgressReporter -> ((outerArgs -> innerArg -> IO ()) -> IO ()) -> IO TestRunResult
- exceptionHandlers :: [Handler (Either SomeException a)]
- type Test = IO ()
- data TestRunSettings = TestRunSettings {}
- defaultTestRunSettings :: TestRunSettings
- data SeedSetting
- = RandomSeed
- | FixedSeed !Int
- data TestRunResult = TestRunResult {
- testRunResultStatus :: !TestStatus
- testRunResultException :: !(Maybe SomeException)
- testRunResultNumTests :: !(Maybe Word)
- testRunResultNumShrinks :: !(Maybe Word)
- testRunResultFailingInputs :: [String]
- testRunResultLabels :: !(Maybe (Map [String] Int))
- testRunResultClasses :: !(Maybe (Map String Int))
- testRunResultTables :: !(Maybe (Map String (Map String Int)))
- testRunResultGoldenCase :: !(Maybe GoldenCase)
- testRunResultExtraInfo :: !(Maybe String)
- data TestStatus
- data Assertion
- data Contextual = forall e.Exception e => Contextual !e !String
- addContextToException :: Exception e => e -> String -> Contextual
- data GoldenCase
- type ProgressReporter = Progress -> IO ()
- noProgressReporter :: ProgressReporter
- reportProgress :: ProgressReporter -> Progress -> IO ()
- data Progress
- timeItT :: MonadIO m => Int -> m a -> m (Timed a)
- timeItDuration :: MonadIO m => m a -> m (a, Word64)
- timeItBeginEnd :: MonadIO m => m a -> m (a, (Word64, Word64))
- data Timed a = Timed {
- timedValue :: !a
- timedWorker :: !Int
- timedBegin :: !Word64
- timedEnd :: !Word64
- timedTime :: Timed a -> Word64
Documentation
runTest :: e -> TestRunSettings -> ProgressReporter -> ((Arg1 e -> Arg2 e -> IO ()) -> IO ()) -> IO TestRunResult Source #
Running the test, safely
Instances
IsTest Property Source # | |
IsTest Bool Source # | |
IsTest (IO (GoldenTest a)) Source # | |
Defined in Test.Syd.Run type Arg1 (IO (GoldenTest a)) Source # type Arg2 (IO (GoldenTest a)) Source # runTest :: IO (GoldenTest a) -> TestRunSettings -> ProgressReporter -> ((Arg1 (IO (GoldenTest a)) -> Arg2 (IO (GoldenTest a)) -> IO ()) -> IO ()) -> IO TestRunResult Source # | |
IsTest (IO ()) Source # | |
IsTest (GoldenTest a) Source # | |
Defined in Test.Syd.Run type Arg1 (GoldenTest a) Source # type Arg2 (GoldenTest a) Source # runTest :: GoldenTest a -> TestRunSettings -> ProgressReporter -> ((Arg1 (GoldenTest a) -> Arg2 (GoldenTest a) -> IO ()) -> IO ()) -> IO TestRunResult Source # | |
IsTest (arg -> Property) Source # | |
IsTest (arg -> IO (GoldenTest a)) Source # | |
Defined in Test.Syd.Run type Arg1 (arg -> IO (GoldenTest a)) Source # type Arg2 (arg -> IO (GoldenTest a)) Source # runTest :: (arg -> IO (GoldenTest a)) -> TestRunSettings -> ProgressReporter -> ((Arg1 (arg -> IO (GoldenTest a)) -> Arg2 (arg -> IO (GoldenTest a)) -> IO ()) -> IO ()) -> IO TestRunResult Source # | |
IsTest (arg -> IO ()) Source # | |
IsTest (arg -> GoldenTest a) Source # | |
Defined in Test.Syd.Run type Arg1 (arg -> GoldenTest a) Source # type Arg2 (arg -> GoldenTest a) Source # runTest :: (arg -> GoldenTest a) -> TestRunSettings -> ProgressReporter -> ((Arg1 (arg -> GoldenTest a) -> Arg2 (arg -> GoldenTest a) -> IO ()) -> IO ()) -> IO TestRunResult Source # | |
IsTest (arg -> Bool) Source # | |
IsTest (outerArgs -> ReaderT env IO ()) Source # | |
IsTest (outerArgs -> innerArg -> Property) Source # | |
Defined in Test.Syd.Run runTest :: (outerArgs -> innerArg -> Property) -> TestRunSettings -> ProgressReporter -> ((Arg1 (outerArgs -> innerArg -> Property) -> Arg2 (outerArgs -> innerArg -> Property) -> IO ()) -> IO ()) -> IO TestRunResult Source # | |
IsTest (outerArgs -> innerArg -> IO (GoldenTest a)) Source # | |
Defined in Test.Syd.Run type Arg1 (outerArgs -> innerArg -> IO (GoldenTest a)) Source # type Arg2 (outerArgs -> innerArg -> IO (GoldenTest a)) Source # runTest :: (outerArgs -> innerArg -> IO (GoldenTest a)) -> TestRunSettings -> ProgressReporter -> ((Arg1 (outerArgs -> innerArg -> IO (GoldenTest a)) -> Arg2 (outerArgs -> innerArg -> IO (GoldenTest a)) -> IO ()) -> IO ()) -> IO TestRunResult Source # | |
IsTest (outerArgs -> innerArg -> IO ()) Source # | |
Defined in Test.Syd.Run runTest :: (outerArgs -> innerArg -> IO ()) -> TestRunSettings -> ProgressReporter -> ((Arg1 (outerArgs -> innerArg -> IO ()) -> Arg2 (outerArgs -> innerArg -> IO ()) -> IO ()) -> IO ()) -> IO TestRunResult Source # | |
IsTest (outerArgs -> innerArg -> GoldenTest a) Source # | |
Defined in Test.Syd.Run type Arg1 (outerArgs -> innerArg -> GoldenTest a) Source # type Arg2 (outerArgs -> innerArg -> GoldenTest a) Source # runTest :: (outerArgs -> innerArg -> GoldenTest a) -> TestRunSettings -> ProgressReporter -> ((Arg1 (outerArgs -> innerArg -> GoldenTest a) -> Arg2 (outerArgs -> innerArg -> GoldenTest a) -> IO ()) -> IO ()) -> IO TestRunResult Source # | |
IsTest (outerArgs -> innerArg -> Bool) Source # | |
Defined in Test.Syd.Run runTest :: (outerArgs -> innerArg -> Bool) -> TestRunSettings -> ProgressReporter -> ((Arg1 (outerArgs -> innerArg -> Bool) -> Arg2 (outerArgs -> innerArg -> Bool) -> IO ()) -> IO ()) -> IO TestRunResult Source # | |
IsTest (ReaderT env IO ()) Source # | |
runPureTestWithArg :: (outerArgs -> innerArg -> Bool) -> TestRunSettings -> ProgressReporter -> ((outerArgs -> innerArg -> IO ()) -> IO ()) -> IO TestRunResult Source #
applyWrapper2 :: forall r outerArgs innerArg. ((outerArgs -> innerArg -> IO ()) -> IO ()) -> (outerArgs -> innerArg -> IO r) -> IO (Either SomeException r) Source #
runIOTestWithArg :: (outerArgs -> innerArg -> IO ()) -> TestRunSettings -> ProgressReporter -> ((outerArgs -> innerArg -> IO ()) -> IO ()) -> IO TestRunResult Source #
runPropertyTestWithArg :: forall outerArgs innerArg. (outerArgs -> innerArg -> Property) -> TestRunSettings -> ProgressReporter -> ((outerArgs -> innerArg -> IO ()) -> IO ()) -> IO TestRunResult Source #
aroundProp :: ((a -> b -> IO ()) -> IO ()) -> (a -> b -> Prop) -> Prop Source #
aroundRose :: ((a -> b -> IO ()) -> IO ()) -> (a -> b -> Rose Result) -> Rose Result Source #
data GoldenTest a Source #
A golden test for output of type a
.
The purpose of a golden test is to ensure that the output of a certain process does not change even over time.
Golden tests can also be used to show how the output of a certain process changes over time and force code reviewers to review the diff that they see in the PR.
This works by saving a golden
output in the repository somewhere,
committing it, and then compare that golden output to the output that is
currently being produced. You can use `--golden-reset` to have sydtest
update the golden output by writing the current output.
GoldenTest | |
|
Instances
runGoldenTestWithArg :: (outerArgs -> innerArg -> IO (GoldenTest a)) -> TestRunSettings -> ProgressReporter -> ((outerArgs -> innerArg -> IO ()) -> IO ()) -> IO TestRunResult Source #
exceptionHandlers :: [Handler (Either SomeException a)] Source #
data TestRunSettings Source #
Instances
data SeedSetting Source #
Instances
HasCodec SeedSetting Source # | |
Defined in Test.Syd.Run | |
Generic SeedSetting Source # | |
Defined in Test.Syd.Run type Rep SeedSetting :: Type -> Type # from :: SeedSetting -> Rep SeedSetting x # to :: Rep SeedSetting x -> SeedSetting # | |
Show SeedSetting Source # | |
Defined in Test.Syd.Run showsPrec :: Int -> SeedSetting -> ShowS # show :: SeedSetting -> String # showList :: [SeedSetting] -> ShowS # | |
Eq SeedSetting Source # | |
Defined in Test.Syd.Run (==) :: SeedSetting -> SeedSetting -> Bool # (/=) :: SeedSetting -> SeedSetting -> Bool # | |
type Rep SeedSetting Source # | |
Defined in Test.Syd.Run type Rep SeedSetting = D1 ('MetaData "SeedSetting" "Test.Syd.Run" "sydtest-0.15.1.1-CZvd3rDS4m47TQqIsce9VY" 'False) (C1 ('MetaCons "RandomSeed" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "FixedSeed" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Int))) |
data TestRunResult Source #
TestRunResult | |
|
Instances
data TestStatus Source #
Instances
Generic TestStatus Source # | |
Defined in Test.Syd.Run type Rep TestStatus :: Type -> Type # from :: TestStatus -> Rep TestStatus x # to :: Rep TestStatus x -> TestStatus # | |
Show TestStatus Source # | |
Defined in Test.Syd.Run showsPrec :: Int -> TestStatus -> ShowS # show :: TestStatus -> String # showList :: [TestStatus] -> ShowS # | |
Eq TestStatus Source # | |
Defined in Test.Syd.Run (==) :: TestStatus -> TestStatus -> Bool # (/=) :: TestStatus -> TestStatus -> Bool # | |
type Rep TestStatus Source # | |
A special exception that sydtest knows about and can display nicely in the error output
This is exported outwards so that you can define golden tests for custom types.
You will probably not want to use this directly in everyday tests, use shouldBe
or a similar function instead.
Instances
data Contextual Source #
An exception with context.
We wrap an existentially qualified exception here, instead of
SomeException
, so that we can unwrap it.
(For some unknown reason, that doesn't work otherwise.)
forall e.Exception e => Contextual !e !String |
Instances
Exception Contextual Source # | |
Defined in Test.Syd.Run toException :: Contextual -> SomeException # fromException :: SomeException -> Maybe Contextual # displayException :: Contextual -> String # | |
Show Contextual Source # | |
Defined in Test.Syd.Run showsPrec :: Int -> Contextual -> ShowS # show :: Contextual -> String # showList :: [Contextual] -> ShowS # |
addContextToException :: Exception e => e -> String -> Contextual Source #
data GoldenCase Source #
Instances
Generic GoldenCase Source # | |
Defined in Test.Syd.Run type Rep GoldenCase :: Type -> Type # from :: GoldenCase -> Rep GoldenCase x # to :: Rep GoldenCase x -> GoldenCase # | |
Show GoldenCase Source # | |
Defined in Test.Syd.Run showsPrec :: Int -> GoldenCase -> ShowS # show :: GoldenCase -> String # showList :: [GoldenCase] -> ShowS # | |
Eq GoldenCase Source # | |
Defined in Test.Syd.Run (==) :: GoldenCase -> GoldenCase -> Bool # (/=) :: GoldenCase -> GoldenCase -> Bool # | |
type Rep GoldenCase Source # | |
Defined in Test.Syd.Run type Rep GoldenCase = D1 ('MetaData "GoldenCase" "Test.Syd.Run" "sydtest-0.15.1.1-CZvd3rDS4m47TQqIsce9VY" 'False) (C1 ('MetaCons "GoldenNotFound" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "GoldenStarted" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "GoldenReset" 'PrefixI 'False) (U1 :: Type -> Type))) |
type ProgressReporter = Progress -> IO () Source #
reportProgress :: ProgressReporter -> Progress -> IO () Source #
Instances
timeItT :: MonadIO m => Int -> m a -> m (Timed a) Source #
Time an action and return the result as well as how long it took in seconds.
This function does not use the timeit
package because that package uses CPU time instead of system time.
That means that any waiting, like with threadDelay
would not be counted.
Note that this does not evaluate the result, on purpose.
timeItDuration :: MonadIO m => m a -> m (a, Word64) Source #
Timed | |
|
Instances
Functor Timed Source # | |
Generic (Timed a) Source # | |
Show a => Show (Timed a) Source # | |
Eq a => Eq (Timed a) Source # | |
type Rep (Timed a) Source # | |
Defined in Test.Syd.Run type Rep (Timed a) = D1 ('MetaData "Timed" "Test.Syd.Run" "sydtest-0.15.1.1-CZvd3rDS4m47TQqIsce9VY" 'False) (C1 ('MetaCons "Timed" 'PrefixI 'True) ((S1 ('MetaSel ('Just "timedValue") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 a) :*: S1 ('MetaSel ('Just "timedWorker") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Int)) :*: (S1 ('MetaSel ('Just "timedBegin") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Word64) :*: S1 ('MetaSel ('Just "timedEnd") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Word64)))) |