1
1
mirror of https://github.com/qfpl/applied-fp-course.git synced 2024-11-26 14:43:53 +03:00
applied-fp-course/level03
Sean Chalmers 8b7b5e4660
Merge pull request #38 from RacingTadpole/patch-3
Add how to run tests in repl
2018-02-09 08:32:42 +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 Merge pull request #38 from RacingTadpole/patch-3 2018-02-09 08:32:42 +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 level03-tests

# Stack
$ stack ghci level03:level03-tests

To run the tests in the repl:

*Main> :main

Start in tests/Test.hs.