Arne
Arne

Reputation: 41

Run HUnit without output

I have a Test:

test1 = TestCase (assertEqual "Bla" 2 (add1 1))

And want to run it in another Haskell programm without automatic I/O output which

runTestTT test1

would create. I tried

runTestText (putTextToHandle stderr False) test1 

but this will still create output. Is there a way (maybe another Handle instead of stderr/stdout) to stop the test from creating output?

I would like to just get the IO Counts to use them at another place.

Upvotes: 0

Views: 102

Answers (1)

ErikR
ErikR

Reputation: 52039

This PutText doesn't produce any output:

foo = runTestText (PutText go 0) test1
  where go :: String -> Bool -> Int -> IO Int
        go s b i = return 0

Here foo has type IO (Counts, Int), so you get the counts with just:

do (counts, _) <- foo
   ...

Upvotes: 1

Related Questions