[英]Running HUnit tests with Hspec
I want to run HUnit tests inside a spec: 我想在规范内运行HUnit测试:
module SHCSpec (spec)
where
import Test.Hspec
import Test.Hspec.Contrib.HUnit
import Test.HUnit
import SHC.Types
import SHC.Lix
spec :: Spec
spec = do
fromHUnitTest ("SHC.Lix" ~: "toHit" ~:
[ Irrelevant @=? toHit []
, None @=? toHit [False]
, None @=? toHit [False, False]
, Partial @=? toHit [False, True]
, Partial @=? toHit [True, False]
, Partial @=? toHit [False, False, True]
, Partial @=? toHit [False, True, False]
, Partial @=? toHit [True, False, False]
, Full @=? toHit [True]
, Full @=? toHit [True, True]
])
The above code works, but it produces this ugly output: 上面的代码可以工作,但是会产生以下丑陋的输出:
SHC
SHC.Lix
toHit
<unlabeled>
<unlabeled>
<unlabeled>
<unlabeled>
<unlabeled>
<unlabeled>
<unlabeled>
<unlabeled>
<unlabeled>
<unlabeled>
Is it possible to attach the label toHit
to every test case? 是否可以将标签
toHit
到每个测试用例上? Something like this: 像这样:
SHC
SHC.Lix
toHit
toHit
toHit
toHit
toHit
toHit
toHit
toHit
toHit
toHit
Even better would be to append a number to each toHit
case. 更好的方法是在每个
toHit
案例toHit
附加一个数字。 I messed with TestList
and map TestLabel
to no avail. 我搞砸了
TestList
并map TestLabel
无济于事。
How about attaching labels to all the tests with a function like: 如何使用以下功能将标签附加到所有测试中:
label ts =
[ show i ~: t | (i,t) <- zip [(1::Int)..] ts ]
Just prefix your list of tests with a call to label
: 只需在您的测试列表前面加上对
label
的调用即可:
spec :: Spec
spec = do
fromHUnitTest ("SHC.Lix" ~: "toHit" ~:
label
[ Irrelevant @=? toHit []
, None @=? toHit [False]
...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.