Test discovery for the tasty framework. https://github.com/lwm/tasty-discover#readme

Version on this page:1.0.1
LTS Haskell 10.6:4.1.3
Stackage Nightly 2017-12-24:4.1.2
Latest on Hackage:4.1.3

See all snapshots tasty-discover appears in

MIT licensed by Luke Murphy
Maintained by Luke Murphy

Module documentation for 1.0.1

Build Status tasty-discover-nightly tasty-discover-lts Hackage Status GitHub license


Automatic test discovery and runner for the tasty framework.

Getting Started

There's 4 simple steps:

  1. Create a test driver file in the test directory
  2. Mark the driver file as the main-is in the test suite
  3. Mark tests with the correct prefixes
  4. Customise test discovery as needed

Check out the example project to get moving quickly.

Create Test Driver File

You can name this file anything you want but it must contain the correct preprocessor definition for tasty-discover to run and also, to detect the configuration. It should be in the top level of the test directory.

For example (in test/Driver.hs):

{-# OPTIONS_GHC -F -pgmF tasty-discover #-}

Configure Cabal Test Suite

In order for Cabal/Stack to know where the tests are, you'll need to configure the main-is option of your test-suite to point to the driver file. In the following example, the test driver file is called Driver.hs:

test-suite test
  main-is: Driver.hs
  hs-source-dirs: tests
  build-depends: base

If you use hpack, that might look like:

    main: "Driver.hs"
    source-dirs: "test"
    - "base"

Write Tests

Create test modules and correctly prefix the tests with the name that corresponds to the testing library you wish to run the test with:

Here's an example test module:

{-# LANGUAGE ScopedTypeVariables #-}

module ExampleTest where

import Data.List
import Test.Tasty
import Test.Tasty.HUnit
import Test.Tasty.Hspec
import Test.Tasty.QuickCheck

-- HUnit test case
unit_listCompare :: IO ()
unit_listCompare = [1, 2, 3] `compare` [1,2] @?= GT

-- QuickCheck property
prop_additionCommutative :: Int -> Int -> Bool
prop_additionCommutative a b = a + b == b + a

-- SmallSheck property
scprop_sortReverse :: [Int] -> Bool
scprop_sortReverse list = sort list == sort (reverse list)

-- Hspec specification
spec_prelude :: Spec
spec_prelude = do
  describe "Prelude.head" $ do
    it "returns the first element of a list" $ do
      head [23 ..] `shouldBe` (23 :: Int)

-- Tasty TestTree
test_multiplication :: [TestTree]
test_multiplication = [testProperty "One is identity" $ \(a :: Int) -> a * 1 == a]

-- Tasty IO TestTree
test_generateTree :: IO TestTree
test_generateTree = do
  input <- pure "Some input"
  pure $ testCase input $ pure ()

-- Tasty IO [TestTree]
test_generateTrees :: IO [TestTree]
test_generateTrees = do
  inputs <- pure ["First input", "Second input"]
  pure $ map (\s -> testCase s $ pure ()) inputs

Customise Discovery

You configure tasty-discover by passing options to the test driver file.

No Arguments

Example: {-# OPTIONS_GHC -F -pgmF tasty-discover -optF --debug #-}

  • --debug: Output the contents of the generated module while testing.
  • --tree-display: Display the test output results hierarchically.

With Arguments

Example: {-# OPTIONS_GHC -F -pgmF tasty-discover -optF --modules="*CustomTest.hs" #-}

  • --modules: Which test modules to discover (with glob pattern).
  • --ignores: Which test modules to ignore (with glob pattern).
  • --generated-module: The name of the generated test module.
  • --ingredient: Tasty ingredients to add to your test runner.

It is also possible to override tasty arguments with -optF:

{-# OPTIONS_GHC -F -pgmF tasty-discover -optF --hide-successes #-}

Example Project

See the testing for this package for a fully configured example.

Change Log

Please see the CHANGELOG.md for the latest changes.

Deprecation Policy

If a breaking change is implemented, you'll see a major version increase, an entry in the change log and a compile time error with a deprecation warning and clear instructions on how to upgrade. Please do complain if we're doing this too much.


All contributions welcome!


If you're interested in helping maintain this package, please let @lwm know!


Thanks to hspec-discover and tasty-auto for making this possible.


Change Log

All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog and this project adheres to Semantic Versioning.

4.1.3 [2018-01-01]


  • Re-enable on Stackage due to tasty/tasty-hedgehog failure (see issue [#132]).

4.1.2 [2017-12-19]


  • Escaping issues for the Windows platform (see issue #124).

4.1.1 [2017-09-26]


  • Incorrect test case doing bad comparison (see issue #123).

4.1.0 [2017-09-26]


  • Find tests recursively in test directory. (see pull request #122).


  • Add ability to override tasty arguments (see pull request #120).

4.0.0 [2017-09-01]


  • Deprecated --[no-]module-suffix for --modules (see pull request #117).
  • Deprecated --ignore-module for --ignores (see pull request #117).


  • tasty-hedgehog is now a supported test library.


  • case_ prefixes have been removed.

3.0.2 [2017-06-05]


  • Make upper bounds for dependencies looser.
  • Fix typo in README.md option documentation.


  • Remove TOC, the hyperlinks weren't working on Hackage.

3.0.1 [2017-06-04]


  • Fixed CHANGELOG.md rendering for Hackage (see pull request #106).


  • Add missing --tree-display documentation note (see pull request #107).

3.0.0 [2017-06-03]


  • Add --tree-display configuration option (see pull request #103).


  • Deprecate case_ in favour of unit_ for HUnit test cases (see pull request #97).


  • Correctly handle sub-directories when using --no-module-suffix (see pull request #102).

2.0.3 [2017-04-13]


  • Make the Cabal description more clear for Hackage.

2.0.2 [2017-04-13]


  • README.md and CHANGELOG.md included for Hackage (see pull request #96).
  • Re-add stylish-haskell automated checking (see pull request #88).

2.0.1 [2017-03-18]


  • Fix flaky test comparison (see pull request #86).


  • Remove the Test.Tasty.Type module (see pull request #83).

2.0.0 [2017-03-15]


  • Add new hpack format.
  • Add generator style test discovery from tasty-auto.
  • Add new configuration options: debug, ingredients and module name.
  • Add unit tests for all functionality.


  • Re-license to MIT.


  • RTD documentation.
  • TemplateHaskell dependency
  • Example project and integration test project.


  • Move all tests into test folder.

1.1.0 [2017-01-19]


  • Add --ignore-module configuration option.

1.0.1 [2017-11-13]


  • Add Cabal and Documentation testing on Travis CI.


  • Include missing extra-source-files.
  • Slim down LICENSE.md and mark as GPL-3 in Cabal file.

1.0.0 [2016-11-04]


  • Add documentation on RTD.
  • Release on Hackage and Stackage.

0.0.3 [2016-09-20]


  • --no-module-suffix configuration option.

0.0.2 [2016-02-20]


  • --module-suffix configuration option.

0.0.1 [2016-02-13]

  • tasty-discover initial release.
Used by 1 package:
comments powered byDisqus