novah.test
A lightweight test library.
Tests can be either automatically registered
with the test and testWith function
and ran with runAllTests or runTestsFor
or manually created with the Test, Tests and Setup constructors
and ran with runTests.
Types
Suite
visibility: public+
constructors: Test, Tests, Setup
Represents one or more tests to be run.
TestResult
visibility: public+
constructors: Success, Failure, Error
All possible results for a test suite.
Declarations
Test
visibility: public
type: String -> (Unit -> Unit) -> Suite
Tests
visibility: public
type: String -> List (Unit -> Unit) -> Suite
Setup
visibility: public
type: { after : Unit -> Unit, before : Unit -> Unit, suite : Suite } -> SuiteSuccess
visibility: public
type: TestResult
Failure
visibility: public
type: TestResult
Error
visibility: public
type: TestResult
allRegisteredtests
visibility: private
type: List Suite
test
visibility: public
type: String -> (Unit -> Unit) -> Unit
Register a test function.
testWith
visibility: public
type: (Unit -> Unit) -> (Unit -> Unit) -> String -> (Unit -> Unit) -> Unit
Register a test function with a before and after hook.
withTable
visibility: public
type: List { | r } -> ({ | r } -> Unit) -> UnitExecutes the function for every entry in the table. Ex:
withTable
[ { animal: "Cat", sound: "meow" }
, { animal: "Dog", sound: "woof" }
, { animal: "Duck", sound: "quack" }
]
\{animal, sound} -> makeSound animal `shouldBe` sound
runTests
visibility: public
type: List Suite -> TestResult
Run the specified tests.
runAllTests
visibility: public
type: Unit -> TestResult
Run all registered tests.
Tests need to be located in a root test package.
runTestsFor
visibility: public
type: String -> TestResult
Run all registered tests. Modules containing tests will be searched in the given root package.
shouldBe
visibility: public
type: {{ Equals a }} -> a -> a -> UnitFails the test if x is not equals y.
shouldNotBe
visibility: public
type: {{ Equals a }} -> a -> a -> UnitFails the test if x is equals y.
recordShouldBe
visibility: public
type: { | r } -> { | r } -> UnitFails the test if the record r1 is not equals r2.
recordShouldNotBe
visibility: public
type: { | r } -> { | r } -> UnitFails the test if the record r1 is equals r2.
shouldBeIn
visibility: public
type: {{ Contained a b }} -> a -> b -> UnitFails the test if the element is not inside the container.
shouldNotBeIn
visibility: public
type: {{ Contained a b }} -> a -> b -> UnitFails the test if the element is inside the container.
shouldAllBeIn
visibility: public
type: {{ Contained a b }} -> List a -> b -> UnitFails the test if some element of the list is not inside the container.
shouldBeSome
visibility: public
type: Option a -> Unit
Fails the test if this option is empty.
shouldBeNone
visibility: public
type: Option a -> Unit
Fails the test if this option is not empty.
shouldBeEmpty
visibility: public
type: List a -> Unit
Fails the test if this list is not empty.
shouldNotBeEmpty
visibility: public
type: List a -> Unit
Fails the test if this list is empty.
check
visibility: private
type: String -> (Unit -> Unit) -> List Int32