Różnice
Różnice między wybraną wersją a wersją aktualną.
|
|
pl:dydaktyka:pp:haskell:lab-hunit [2018/06/08 22:52] esimon [Funkcje i typy w HUnit] |
pl:dydaktyka:pp:haskell:lab-hunit [2019/06/27 15:50] |
====== 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: [[http://hackage.haskell.org/package/HUnit|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': | |
| |
<code> | |
stack install HUnit | |
</code> | |
| |
===== Funkcje i typy w HUnit ===== | |
| |
| |
^Funckja^ Sygnatura^ | |
|assert | <code haskell>Assertable t => t -> Assertion</code>| | |
|assertFailure | <code haskell>assertFailure :: String -> Assertion</code>| | |
|assertBool | <code haskell>String -> Bool -> Assertion</code>| | |
|assertEqual | <code haskell>(Show a, Eq a) => String -> a -> a -> Assertion</code>| | |
|assertionPredicate | <code haskell>AssertionPredicable t => t -> AssertionPredicate</code>| | |
|assertString | <code haskell>String -> Assertion</code>| | |
|runTestTT | <code haskell>Test -> IO Counts</code>| | |
| |
| |
^Typ ^ Definicja^ Opis^ | |
|Assertion|type Assertion = IO ()|X| | |
|Count|<code haskell>data Counts = Counts { cases, tried, errors, failures :: Int } | |
deriving (Eq, Show, Read)</code>|X| | |
|Test|<code haskell>data Test = TestCase Assertion | |
| TestList [Test] | |
| TestLabel String Test</code>|X| | |
| |
| |
| |
| |
| |
| |
| |