运行 使用 Hspec 进行 HUnit 测试
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
案例附加一个数字。我搞砸了 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]
...
我想 运行 规范内的 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
案例附加一个数字。我搞砸了 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]
...