hspec-slow: Find slow test cases

[ bsd3, library, testing ] [ Propose Tags ]

Records and prints out slow Hspec tests

[Skip to Readme]


[Index] [Quick Jump]


Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees


Versions [RSS],
Change log Changelog.md
Dependencies base (>=4.7 && <4.15), hspec, hspec-core (>=2.0.0 && <3.0), mtl, stm, time, transformers [details]
License BSD-3-Clause
Copyright 2016 Bob Long
Author Bob Long, riskbook <support@riskbook.com>
Maintainer riskbook <support@riskbook.com>
Category Testing
Home page https://github.com/riskbook/hspec-slow
Bug tracker https://github.com/riskbook/hspec-slow/issues
Source repo head: git clone https://github.com/riskbook/hspec-slow
Uploaded by Jappie at 2020-11-26T10:38:55Z
Reverse Dependencies 1 direct, 0 indirect [details]
Downloads 1064 total (13 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2020-11-26 [all 1 reports]

Readme for hspec-slow-

[back to package description]


Track and display slow specs in Hspec runs.

Example spec

main :: IO ()
main = do
  conf <- configure 1 -- Track specs that take longer than 1s
  timedHspec conf $ \it ->
    describe "Main" $ do
      it "should foo" $ do
        threadDelay 3000000
        1 `shouldBe` 1
      it "should bar" $ do
        threadDelay 1000
        1 `shouldBe` 1
      it "should baz" $ do
        threadDelay 4000000
        1 `shouldBe` 1

Checkout hspec slow everything to run this on your entire test suite.

Example Output

  should foo
  should bar
  should baz
Slow examples:
3.002925s: should foo
4.006186s: should baz

Finished in 7.0141 seconds
3 examples, 0 failures

Parallel specs

Parallel specs are supported. They are run similarly to above:

timedHspecParallel conf $ \it -> do
  -- ...


  should foo
  should bar
  should baz
Slow examples:
3.005728s: should foo
4.00143s: should baz

Finished in 4.0024 seconds
3 examples, 0 failures

hspec slow everything


module Main where

import qualified Spec
import Test.Hspec.Slow
import Test.Hspec(hspec)
import ClassyPrelude

main :: IO ()
main = do
  config <- configure 2
  hspec $ timeThese config Spec.spec


{-# OPTIONS_GHC -fno-warn-implicit-prelude #-}
{-# OPTIONS_GHC -F -pgmF hspec-discover -optF --module-name=Spec #-}