To jest stara wersja strony!
Testy jednostkowe z HUnit
Haskell udostępnia framework do testów jednostkowych o nazwie HUnit, który (podobno ;) ) inspirowany jest JUnitem z Javy.
Pełna dokumentacja: HUnit Documentation
Instalacja
HUnit nie jest domyślnie instalowany wraz z ghc/ghci.
Można go doinstalować, albo z repozytorium (Linux), albo używając pakietu 'haskell-stack':
stack install HUnit
Funkcje i typy w HUnit
Funckja | Sygnatura |
assert | Assertable t => t -> Assertion
|
assertFailure | assertFailure :: String -> Assertion
|
assertBool | String -> Bool -> Assertion
|
assertEqual | (Show a, Eq a) => String -> a -> a -> Assertion
|
assertionPredicate | AssertionPredicable t => t -> AssertionPredicate
|
assertString | String -> Assertion
|
runTestTT | Test -> IO Counts
|
Typ | Definicja | Opis |
Assertion | type Assertion = IO ()
| X |
Count | data Counts = Counts { cases, tried, errors, failures :: Int }
deriving (Eq, Show, Read)
| X |
Test | data Test = TestCase Assertion
| TestList [Test]
| TestLabel String Test
| X |