HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

Moduletasty-hspec-1.2.0.4Haskell2010

Test.Tasty.Hspec

hspec and tasty serve similar purposes; consider using one or the other.

However, in a pinch, this module allows you to run an hspec H.Spec as a tasty T.TestTree.

  • 1 type
  • 2 values

Tests

2 declarations

Options

1 declaration
datadata TreatPendingAs
#

How to treat hspec pending tests.

tasty does not have the concept of pending tests, so we must map them to either successes or failures. By default, they are treated as failures.

Set via the command line flag --treat-pending-as (success|failure).

Instances1IsOption

Examples

0 declarations

The simplest usage of this library involves first creating a T.TestTree in IO, then running it with T.defaultMain.

main = do
  spec <- testSpec "spec" mySpec
  T.defaultMain
    (T.testGroup "tests"
      [ spec
      , ...
      ])

You can treat an H.pending/H.pendingWith test as a success instead of a failure (the default):

tests :: TestTree
tests =
  localOption TreatPendingAsSuccess $ testGroup "My Hspec TestTree"
    [ unsafePerformIO (testSpec "My first Hspec test" spec_firstHspecTest)
    , ...
    ]

If you don't do any IO during Spec creation, or the IO need not be performed at any particular time relative to other IO actions, it's perfectly fine to use System.IO.unsafePerformIO.

main = do
  T.defaultMain
    (T.testGroup "tests"
      [ System.IO.unsafePerformIO (testSpec "spec" mySpec)
      , ...
      ])