据我所知,Haskell 没有 Cucumber 类似物。最接近您正在寻找的可能是 HSpec,它是 RSpec-ish。
这是一个示例,来自 HSpec 网站的逐字记录:
import Test.Hspec
import Test.QuickCheck
import Control.Exception (evaluate)
main :: IO ()
main = hspec $ do
describe "Prelude.head" $ do
it "returns the first element of a list" $ do
head [23 ..] `shouldBe` (23 :: Int)
it "returns the first element of an *arbitrary* list" $
property $ \x xs -> head (x:xs) == (x :: Int)
it "throws an exception if used with an empty list" $ do
evaluate (head []) `shouldThrow` anyException
哪个生产
Prelude.head
- returns the first element of a list
- returns the first element of an *arbitrary* list
- throws an exception if used with an empty list