1
1
mirror of https://github.com/qfpl/applied-fp-course.git synced 2024-12-02 08:53:20 +03:00
applied-fp-course/level03
2018-02-08 06:03:50 +10:00
..
bin Updates based on course run feedback. 2018-01-16 12:36:57 +10:00
src/FirstApp Updates based on course run feedback. 2018-01-16 12:36:57 +10:00
tests Remove obsolete test comment 2018-01-17 13:49:47 +11:00
changelog.md change changelog files to lowercase 2017-09-01 11:17:26 +10:00
default.nix Overhauled nix file setup to be more like the other QFPL projects. 2017-09-18 10:14:29 +10:00
level03.cabal Upgrade CI so we test building with stack as well 2018-02-02 09:59:55 +10:00
level03.nix Updates based on course run feedback. 2018-01-16 12:36:57 +10:00
LICENCE update copyright notice 2017-09-12 11:51:26 +10:00
README.md Update README with cabal test 2018-02-08 06:03:50 +10:00
Setup.hs Added third stage exercise 2017-08-09 15:59:16 +10:00
stack.yaml Update to stackage LTS 10 (GHC 8.2.2) 2018-01-31 12:20:33 +11:00
test.json Updates based on course run feedback. 2018-01-16 12:36:57 +10:00

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.

Including Test Library Dependencies and Running the Tests

For a cabal sandbox:

$ cabal sandbox init
$ cabal install --only-dependencies --enable-tests
$ cabal configure --enable-tests
$ cabal test

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.