在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):hedgehogqa/haskell-hedgehog开源软件地址(OpenSource Url):https://github.com/hedgehogqa/haskell-hedgehog开源编程语言(OpenSource Language):Haskell 100.0%开源软件介绍(OpenSource Introduction):Release with confidence.Hedgehog automatically generates a comprehensive array of test cases, exercising your software in ways human testers would never imagine. Generate hundreds of test cases automatically, exposing even the most insidious of corner cases. Failures are automatically simplified, giving developers coherent, intelligible error messages. Features
ExampleThe main module, Hedgehog, includes almost everything you need to get started writing property tests with Hedgehog. It is designed to be used alongside Hedgehog.Gen and Hedgehog.Range which should be imported qualified. You also need to enable Template Haskell so the Hedgehog test runner can find your properties. {-# LANGUAGE TemplateHaskell #-}
import Hedgehog
import qualified Hedgehog.Gen as Gen
import qualified Hedgehog.Range as Range Once you have your imports set up, you can write a simple property: prop_reverse :: Property
prop_reverse =
property $ do
xs <- forAll $ Gen.list (Range.linear 0 100) Gen.alpha
reverse (reverse xs) === xs And add the Template Haskell splice which will discover your properties: tests :: IO Bool
tests =
checkParallel $$(discover) If you prefer to avoid macros, you can specify the group of properties to run manually instead: {-# LANGUAGE OverloadedStrings #-}
tests :: IO Bool
tests =
checkParallel $ Group "Test.Example" [
("prop_reverse", prop_reverse)
] You can then load the module in GHCi, and run it:
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论