[英]Is it possible to skip tests in HSpec test suite?
在大多數編程語言中,在某些情況下很容易跳過測試。 在基於 haskell HSpec 的測試套件中是否有正確的方法來做到這一點?
“將其更改為 xit 會將相應的規范項目標記為待定。”
來源: http : //hackage.haskell.org/package/hspec-2.7.8/docs/Test-Hspec.html
如果我理解正確的話, HSpec 的核心沒有針對這種情況的特殊解決方案。 但是你可以跳過測試而不用冗長。 例如:
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}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.