haskellhunit

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.


Solution

  • 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
       ...