在大多数编程语言中,在某些情况下很容易跳过测试。在基于haskell HSpec的测试套件中是否有适当的方法来做到这一点?
如果我理解正确,那么HSpec的Core在这种情况下没有特殊的解决方案。但是您可以跳过测试而不必太冗长。例如:
main = hspec $ do
...
when isDatabaseServerRunning $ do
describe "database" $ do
it "test some one" $ do
...
另一个解决方案可能是使用功能,例如mapSpecItem_
将测试结果更改为Pending
带有关于为什么被跳过的消息。例如:
skip :: String -> Bool -> SpecWith a -> SpecWith a
skip _ False = id
skip why True = mapSpecItem_ updateItem
where
updateItem x = x{itemExample = \_ _ _ -> return . Pending . Just $ why}
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句