mirror of
https://github.com/qfpl/applied-fp-course.git
synced 2024-11-26 14:43:53 +03:00
554bdc1e08
Per #28 , added some wording for the `fromIntegral` function. Removed the 'aside' for `ghcid` as this was causing more problems than it was solving. Too many install / usage dramas. Added a snippet for loading a repl with test libraries and packages loaded. Because I had completely forgotten how to do that. |
||
---|---|---|
.. | ||
bin | ||
src/FirstApp | ||
tests | ||
changelog.md | ||
default.nix | ||
level03.cabal | ||
level03.nix | ||
LICENCE | ||
README.md | ||
Setup.hs | ||
stack.yaml | ||
test.json |
Level 03
In this exercise we're going to add some tests to our application. Because types are awesome, and tests are pretty good. But types AND tests is pretty much perfect.
These tests will not be awe inspiring, this exercise is primarily to introduce you to adding tests to your Haskell application. The setup of the Cabal file is already completed for you, but will be covered.
As is to be expected, there are multiple testing frameworks and packages available but we will only cover one here. We will use the HSpec framework, with the hspec-wai package to make our lives a bit easier.
NB: Including Test Library Dependencies
For a cabal sandbox:
$ cabal sandbox init
$ cabal install --only-dependencies --enable-tests
$ cabal configure --enable-tests
For a stack environment:
$ stack build --test
To load the tests in the REPL:
# Cabal
$ cabal repl level04-tests
# Stack
$ stack ghci level04:level04-tests
Start in tests/Test.hs
.