TimedSpecs

TimedSpecs are addons built for and over Hspec.

Note: The timing will only be an approximation as test run times vary from machine to machine.

timedSpec This serves as the runner

timedSpec :: TimedSpec -> IO () main = timedSpec spec spec = do takes ( 2 ` seconds `) $ ...

takes <milliseconds> Specifies the time in milliseconds that a spec takes to run.

takes :: TimeInMillis -> Hspec . Spec -> TimedSpec spec = do takes 4000.0 $ describe "sample" $ do it "takes at most 4000 milliseconds to run" $ do ...

The above test fails if it takes longer than 4000 milliseconds. takes does not stop the test if it runs longer than the specified time.

Convenience methods

To make it easy to specify time, TimedSpecs provides some convenience methods.

seconds

spec = do takes ( 4 ` seconds `) $ describe ...

minutes