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
pl/dydaktyka/pp/haskell/lab-hunit.1528491189.txt.gz · ostatnio zmienione: 2019/06/27 15:54 (edycja zewnętrzna)
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0