[英]Running HUnit tests with Hspec
我想在规范内运行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]
])
上面的代码可以工作,但是会产生以下丑陋的输出:
SHC
SHC.Lix
toHit
<unlabeled>
<unlabeled>
<unlabeled>
<unlabeled>
<unlabeled>
<unlabeled>
<unlabeled>
<unlabeled>
<unlabeled>
<unlabeled>
是否可以将标签toHit
到每个测试用例上? 像这样:
SHC
SHC.Lix
toHit
toHit
toHit
toHit
toHit
toHit
toHit
toHit
toHit
toHit
更好的方法是在每个toHit
案例toHit
附加一个数字。 我搞砸了TestList
并map TestLabel
无济于事。
如何使用以下功能将标签附加到所有测试中:
label ts =
[ show i ~: t | (i,t) <- zip [(1::Int)..] ts ]
只需在您的测试列表前面加上对label
的调用即可:
spec :: Spec
spec = do
fromHUnitTest ("SHC.Lix" ~: "toHit" ~:
label
[ Irrelevant @=? toHit []
, None @=? toHit [False]
...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.