Haskell Language
टेस्टी के साथ टेस्टी
खोज…
स्मॉलकैच, क्विकचेक और हुआनिट
import Test.Tasty
import Test.Tasty.SmallCheck as SC
import Test.Tasty.QuickCheck as QC
import Test.Tasty.HUnit
main :: IO ()
main = defaultMain tests
tests :: TestTree
tests = testGroup "Tests" [smallCheckTests, quickCheckTests, unitTests]
smallCheckTests :: TestTree
smallCheckTests = testGroup "SmallCheck Tests"
[ SC.testProperty "String length <= 3" $
\s -> length (take 3 (s :: String)) <= 3
, SC.testProperty "String length <= 2" $ -- should fail
\s -> length (take 3 (s :: String)) <= 2
]
quickCheckTests :: TestTree
quickCheckTests = testGroup "QuickCheck Tests"
[ QC.testProperty "String length <= 5" $
\s -> length (take 5 (s :: String)) <= 5
, QC.testProperty "String length <= 4" $ -- should fail
\s -> length (take 5 (s :: String)) <= 4
]
unitTests :: TestTree
unitTests = testGroup "Unit Tests"
[ testCase "String comparison 1" $
assertEqual "description" "OK" "OK"
, testCase "String comparison 2" $ -- should fail
assertEqual "description" "fail" "fail!"
]
पैकेज स्थापित करें:
cabal install tasty-smallcheck tasty-quickcheck tasty-hunit
केबल के साथ चलाएं:
cabal exec runhaskell test.hs
Modified text is an extract of the original Stack Overflow Documentation
के तहत लाइसेंस प्राप्त है CC BY-SA 3.0
से संबद्ध नहीं है Stack Overflow