HTF: The Haskell Test Framework

[ lgpl, library, program, testing ] [ Propose Tags ]

The Haskell Test Framework (HTF for short) lets you define unit tests (http://hunit.sourceforge.net), QuickCheck properties (http://www.cs.chalmers.se/~rjmh/QuickCheck/), and black box tests in an easy and convenient way. HTF uses a custom preprocessor that collects test definitions automatically. Furthermore, the preprocessor allows HTF to report failing test cases with exact file name and line number information. Additionally, HTF tries to produce highly readable output for failing tests: for example, it colors and pretty prints expected and actual results and provides a diff between the two values.

The documentation of the Test.Framework.Tutorial module provides a tutorial for HTF. There is also a slightly out-dated blog article (http://factisresearch.blogspot.de/2011/10/new-version-of-htf-with-diffs-colors.html) demonstrating HTF's coloring, pretty-printing and diff functionality.

HEADS UP, backwards incomatibility with prior versions:

In version 0.10.0.0, the following changes could break code compiled against version 0.9.*:

Starting with version 0.9.0.0, HTF uses a new strategy for collecting the testcases defined in your project (see Test.Framework.Tutorial for a description of this strategy). If you used version 0.8.* or earlier of HTF, this will break your build! However, it's rather easy to bring you project in line with the new HTF version. Here are the steps that will most likely resolve your backwards incompatibility problems:

  • If a module exports the allHTFTests symbol, this export must be changed to htf_thisModulesTests.

  • If an import declaration of some module hides the allHTFTests symbol, you can simply remove the hiding clause for allHTFTests.

  • If a module collects and executes tests from several other modules, the collecting module has to be changed as follows: add {-# OPTIONS_GHC -F -pgmF htfpp #-} to the top of the collecting module, import the other modules with the {-@ HTF_TESTS @-} annotation, use the symbol htf_importedTests for referencing the imported tests. See Test.Framework.Tutorial for details.


[Skip to Readme]

Downloads

Note: This package has metadata revisions in the cabal description newer than included in the tarball. To unpack the package including the revisions, use 'cabal get'.

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

Versions [RSS] 0.1, 0.3, 0.3.1, 0.3.2, 0.3.3, 0.3.4, 0.3.5.0, 0.4.0.0, 0.5.0.0, 0.5.0.1, 0.6.0.0, 0.6.0.1, 0.7.0.0, 0.7.0.1, 0.7.1.0, 0.8.0.0, 0.8.1.0, 0.8.1.1, 0.8.2.0, 0.8.2.1, 0.8.2.2, 0.9.0.0, 0.10.0.0, 0.10.0.1, 0.10.0.2, 0.10.0.3, 0.10.0.4, 0.10.0.5, 0.10.0.6, 0.10.0.7, 0.11.0.0, 0.11.0.1, 0.11.1.0, 0.11.1.1, 0.11.2, 0.11.2.1, 0.11.3.0, 0.11.3.1, 0.11.3.2, 0.11.3.4, 0.11.4.0, 0.12.0.0, 0.12.1.0, 0.12.2.0, 0.12.2.1, 0.12.2.2, 0.12.2.3, 0.12.2.4, 0.13.0.0, 0.13.1.0, 0.13.2.1, 0.13.2.2, 0.13.2.4, 0.13.2.5, 0.14.0.0, 0.14.0.1, 0.14.0.2, 0.14.0.3, 0.14.0.4, 0.14.0.5, 0.14.0.6, 0.14.0.7, 0.15.0.0, 0.15.0.1
Change log ChangeLog
Dependencies aeson (>=0.6), array, base (>=4 && <5), bytestring (>=0.9), containers (>=0.4.2.1), cpphs (>=1.12), Diff (>=0.3), directory (>=1.0), haskell-src-exts (>=1.14 && <1.16), HUnit (>=1.2.5 && <1.3), lifted-base (>=0.1), monad-control (>=0.3), mtl (>=1.1 && <2.3), old-time (>=1.0), pretty (>=1.0), process (>=1.0), QuickCheck (>=2.3), random (>=1.0), regex-compat (>=0.92), text (>=0.11), unix (>=2.4), xmlgen (>=0.6) [details]
License LicenseRef-LGPL
Copyright (c) 2005-2012 Stefan Wehr
Author Stefan Wehr <wehr@factisresearch.com>
Maintainer Stefan Wehr <wehr@factisresearch.com>
Revised Revision 2 made by AndreasAbel at 2023-02-25T15:07:54Z
Category Testing
Home page https://github.com/skogsbaer/HTF/
Bug tracker https://github.com/skogsbaer/HTF/issues
Source repo head: git clone http://github.com/skogsbaer/HTF.git
Uploaded by StefanWehr at 2014-02-10T19:22:57Z
Distributions Arch:0.15.0.1, LTSHaskell:0.15.0.1, NixOS:0.15.0.1, Stackage:0.15.0.1
Reverse Dependencies 7 direct, 7 indirect [details]
Executables htfpp
Downloads 67370 total (118 in the last 30 days)
Rating 2.0 (votes: 1) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Successful builds reported [all 1 reports]

Readme for HTF-0.11.2.1

[back to package description]

HTF - The Haskell Test Framework

Summary

The Haskell Test Framework (HTF for short) lets you define unit tests (http://hunit.sourceforge.net), QuickCheck properties (http://www.cs.chalmers.se/~rjmh/QuickCheck/), and black box tests in an easy and convenient way. HTF uses a custom preprocessor that collects test definitions automatically. Furthermore, the preprocessor allows HTF to report failing test cases with exact file name and line number information. Additionally, HTF tries to produce highly readable output for failing tests: for example, it colors and pretty prints expected and actual results and provides a diff between the two values.

Look here for a short tutorial on HTF. The following slightly out-dated blog article demonstrates HTF's coloring, pretty-printing and diff functionality.

Installation instructions

  • Install from http://hackage.haskell.org/ using cabal install HTF

  • Install from source:

      $ git clone git@github.com:skogsbaer/HTF.git
      $ cd HTF
      $ cabal install
    

Getting started

  • Read the tutorial.
  • Experiment with the sample project located in the sample directory of HTF's source tree.