1
1
mirror of https://github.com/qfpl/applied-fp-course.git synced 2024-11-26 06:38:40 +03:00
applied-fp-course/level03
George Wilson bbfae6a6d6 Add support for GHC 8.4.1
Also remove 7.8 with lower bounds, since we don't support it.
2018-03-29 21:18:06 +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 Add support for GHC 8.4.1 2018-03-29 21:18:06 +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 Fix stack ghci instruction 2018-03-24 11:27:55 -06: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 level03-tests

# Stack
$ stack ghci level03:test:level03-tests

To run the tests in the repl:

*Main> :main

Start in tests/Test.hs.