tasty-discover: Test discovery for the tasty framework.

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

Automatic test discovery and runner for the tasty framework. Prefix your test case names and tasty-discover will discover, collect and run them. All popular test libraries are covered. Configure once and then just write your tests. Avoid forgetting to add test modules to your Cabal/Hpack files. Tasty ingredients are included along with various configuration options for different use cases. Please see the README.md below for how to get started.


[Skip to Readme]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

Versions [RSS] 1.0.0, 1.0.1, 1.1.0, 2.0.0, 2.0.1, 2.0.2, 2.0.3, 3.0.0, 3.0.1, 3.0.2, 4.0.0, 4.1.0, 4.1.1, 4.1.2, 4.1.3, 4.1.4, 4.1.5, 4.2.0, 4.2.1, 4.2.2, 4.2.3, 4.2.4, 5.0.0
Change log CHANGELOG.md
Dependencies base (>=4.8 && <5), directory (>=1.1 && <1.4), filepath (>=1.3 && <1.5), tasty-discover [details]
License MIT
Copyright 2016 Luke Murphy
Author Luke Murphy
Maintainer Luke Murphy <lukewm@riseup.net>
Category Testing
Home page https://github.com/lwm/tasty-discover#readme
Bug tracker https://github.com/lwm/tasty-discover/issues
Source repo head: git clone https://github.com/lwm/tasty-discover
Uploaded by lwm at 2017-04-13T12:43:42Z
Distributions Arch:5.0.0, Debian:4.2.1, LTSHaskell:5.0.0, NixOS:5.0.0, Stackage:5.0.0
Reverse Dependencies 5 direct, 0 indirect [details]
Executables tasty-discover
Downloads 18526 total (134 in the last 30 days)
Rating 2.25 (votes: 2) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2017-04-13 [all 1 reports]

Readme for tasty-discover-2.0.3

[back to package description]

Build Status Hackage Status Stackage Status GitHub license

tasty-discover

Automatic test discovery and runner for the tasty framework.

Getting Started

Usage GIF

5 steps to tasty test discovery satori:

  • Create a Tasty.hs in the hs-source-dirs of your test suite.
  • Set your test suite main-is to the Tasty.hs.
  • Create test modules in files with suffix *Test.hs or *Spec.hs.
  • Write your tests with the following prefixes:

Examples

{-# LANGUAGE ScopedTypeVariables #-}

module ExampleTest where

import Test.Tasty
import Test.Tasty.HUnit
import Test.Tasty.Hspec
import Test.Tasty.QuickCheck

-- HUnit test case
case_listCompare :: IO ()
case_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

Configuration

Pass configuration options within your Tasty.hs like so:

{-#
 OPTIONS_GHC -F -pgmF tasty-discover
 -optF <OPTION>
 -optF <OPTION>
#-}

No Arguments

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

  • --no-module-suffix: Collect all test modules, regardless of module suffix.
  • --debug: Output the contents of the generated module while testing.

With Arguments

Example: {-# OPTIONS_GHC -F -pgmF tasty-discover -optF --moduleSuffix=FooBar #-}

  • --module-suffix: Which test module suffix you wish to have discovered.
  • --generated-module: The name of the generated test module.
  • --ignore-module: Which test modules to ignore from discovery.
  • --ingredient: Tasty ingredients to add to your test runner.

Change Log

See the Change log for the latest changes.

Contributing

All contributions welcome!

Acknowledgements

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