简体   繁体   中英

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM