tasty-silver-3.3.1.2: A fancy test runner, including support for golden tests.
Safe HaskellNone
LanguageHaskell2010

Test.Tasty.Silver.Advanced

Synopsis

Constructing golden tests

goldenTest1 Source #

Arguments

:: TestName

test name

-> IO (Maybe a)

get the golden correct value

-> IO a

get the tested value

-> (a -> a -> GDiff)

comparison function.

If two values are the same, it should return Equal. If they are different, it should return a diff representation. First argument is golden value.

-> (a -> GShow)

Show the golden/actual value.

-> (a -> IO ())

update the golden file

-> TestTree 

A very general testing function.

goldenTestIO Source #

Arguments

:: TestName

test name

-> IO (Maybe a)

get the golden correct value

-> IO a

get the tested value

-> (a -> a -> IO GDiff)

comparison function.

If two values are the same, it should return Equal. If they are different, it should return a diff representation. First argument is golden value.

-> (a -> IO GShow)

Show the golden/actual value.

-> (a -> IO ())

update the golden file

-> TestTree 

A very general testing function. The IO version of show/diff are useful when using external diff or show mechanisms. If IO is not required, the goldenTest1 function should be used instead.

goldenTestIO1 Source #

Arguments

:: TestName

test name

-> IO (Maybe a)

get the golden correct value

-> IO a

get the tested value

-> (a -> a -> IO GDiff)

comparison function.

If two values are the same, it should return Equal. If they are different, it should return a diff representation. First argument is golden value.

-> (a -> IO GShow)

Show the golden/actual value.

-> Maybe (a -> IO ())

update the golden file

-> TestTree 

A very general testing function. Experimental function, may change in later versions! The IO version of show/diff are useful when using external diff or show mechanisms. If IO is not required, the goldenTest1 function should be used instead.

goldenTest Source #

Arguments

:: TestName

test name

-> IO a

get the golden correct value

-> IO a

get the tested value

-> (a -> a -> IO (Maybe String))

comparison function.

If two values are the same, it should return Nothing. If they are different, it should return an error that will be printed to the user. First argument is the golden value.

The function may use IO, for example, to launch an external diff command.

-> (a -> IO ())

update the golden file

-> TestTree 

A very general testing function. Use goldenTest1 instead if you can.

data GShow Source #

How to show a value to the user.

Constructors

ShowText Text

Show the given text.

data GDiff Source #

The comparison/diff result.

Constructors

Equal

Values are equal.

DiffText

The two values are different, show a diff between the two given texts.

ShowDiffed

The two values are different, just show the given text to the user.

Fields

Reading files

readFileMaybe :: FilePath -> IO (Maybe ByteString) Source #

Read the file if it exists, else return Nothing. Useful for reading golden files.