1
1
mirror of https://github.com/qfpl/applied-fp-course.git synced 2024-11-29 16:55:12 +03:00
applied-fp-course/level03
George Wilson 020961d4a2
Merge pull request #49 from qfpl/travis-chgs
Travis changes & Version Bumps
2018-03-29 11:05:52 +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 Bump some upper bounds, and replace <= with < in upper bounds 2018-03-28 11:04:07 +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.