This repository accompanies the Testing Series on the Monday Morning Haskell blog. The series give a tutorial for a few different essential testing tools in Haskell, including HUnit, HSpec and Criterion. You can read the code in the articles and follow along with the examples here. There are a couple special "practice" modules where you can try out the examples for yourself. See FencesPractice.hs and FencesPracticeTests.hs, as referenced in part 3 of the series.
Start by building the code:
>> stack build
You can then run a series of test suites and benchmarks associated with the library:
>> stack build Testing:test:unit-test
>> stack build Testing:test:spec-test
>> stack build Testing:test:fences-tests
>> stack build Testing:bench:fences-benchmark
>> stack build Testing:test:fences-fast-tests
>> stack build Testing:bench:fences-fast-benchmark
You're also encouraged to try running the benchmarks with the --profile
option. This will enable you to see the profiling output for better debugging.
>> stack build Testing:bench:fences-benchmark
>> stack build Testing:bench:fences-fast-benchmark
Note that when you switch between compiling any part of the project with --profile
and without the option, Stack will need to recompile all modules and dependencies, which can be a length process.
Part 3 of the series presents some data structure improvements we can make to an algorithm introduced in Part 2. You can try writing some of the code for that part yourself in this practice module. You are encouraged to use a "Test-Driven-Development" style and write your tests in this file. You can run this test suite like so:
>> stack build Testing:test:fences-practice-tests