Copyright | Stack Builders (c) 2019-2020 |
---|---|
License | MIT |
Maintainer | cmotoche@stackbuilders.com |
Stability | experimental |
Portability | portable |
Safe Haskell | None |
Language | Haskell2010 |
Golden tests store the expected output in a separated file. Each time a golden test
is executed the output of the subject under test (SUT) is compared with the
expected output. If the output of the SUT changes then the test will fail until
the expected output is updated. We expose defaultGolden
for output of
type String
. If your SUT has a different output, you can use Golden
.
Synopsis
- data Golden str = Golden {
- output :: str
- encodePretty :: str -> String
- writeToFile :: FilePath -> str -> IO ()
- readFromFile :: FilePath -> IO str
- goldenFile :: FilePath
- actualFile :: Maybe FilePath
- failFirstTime :: Bool
- defaultGolden :: String -> String -> Golden String
Documentation
Golden tests parameters
import Data.Text (Text) import qualified Data.Text.IO as T goldenText :: String -> Text -> Golden Text goldenText name actualOutput = Golden { output = actualOutput, encodePretty = prettyText, writeToFile = T.writeFile, readFromFile = T.readFile, goldenFile = ".specific-golden-dir" / name / "golden", actualFile = Just (".specific-golden-dir" / name / "actual"), failFirstTime = False } describe "myTextFunc" $ it "generates the right output with the right params" $ goldenText "myTextFunc" (myTextFunc params)
Golden | |
|
Instances
Eq str => Example (Golden str) Source # | |
Defined in Test.Hspec.Golden evaluateExample :: Golden str -> Params -> (ActionWith (Arg (Golden str)) -> IO ()) -> ProgressCallback -> IO Result # | |
Eq str => Example (arg -> Golden str) Source # | |
Defined in Test.Hspec.Golden evaluateExample :: (arg -> Golden str) -> Params -> (ActionWith (Arg (arg -> Golden str)) -> IO ()) -> ProgressCallback -> IO Result # | |
type Arg (Golden str) Source # | |
Defined in Test.Hspec.Golden | |
type Arg (arg -> Golden str) Source # | |
Defined in Test.Hspec.Golden |