简体   繁体   English

没有输出运行HUnit

[英]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 并希望在没有自动I / O输出的另一个Haskell程序中运行它

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? 有没有办法(也许是另一个Handle而不是stderr / stdout)停止测试创建输出?

I would like to just get the IO Counts to use them at another place. 我只想获取IO计数以在其他地方使用它们。

This PutText doesn't produce any output: PutText不会产生任何输出:

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: 此处foo类型为IO (Counts, Int) ,因此您可以通过以下方式获得计数:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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