tasty-discover

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

LTS Haskell 8.23:1.1.0
Stackage Nightly 2017-07-20:3.0.2
Latest on Hackage:3.0.2
MIT licensed by Luke Murphy
Maintained by Luke Murphy

Module documentation for 1.1.0

Build Status Hackage Status tasty-discover GitHub license

tasty-discover

Automatic test discovery and runner for the tasty framework.

Getting Started

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: - prop_: QuickCheck properties. - scprop_: SmallCheck properties. - unit_: HUnit test cases. - spec_: Hspec specifications. - test_: Tasty TestTrees.

Examples

{-# LANGUAGE ScopedTypeVariables #-}

module ExampleTest where

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

Configuration

Pass configuration options within your Tasty.hs like so:

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

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.
  • --tree-display: Display the test output results hierarchically.

With Arguments

Example: {-# OPTIONS_GHC -F -pgmF tasty-discover -optF --module-suffix=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.

Changes

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.

3.0.2 [2017-06-05]

Fixed

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

Remove

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

3.0.1 [2017-06-04]

Fixed

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

Added

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

3.0.0 [2017-06-03]

Added

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

Changed

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

Fixed

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

2.0.3 [2017-04-13]

Fixed

  • Make the Cabal description more clear for Hackage.

2.0.2 [2017-04-13]

Added

  • 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]

Fixed

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

Removed

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

2.0.0 [2017-03-15]

Added

  • 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.

Fixed

  • Re-license to MIT.

Removed

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

Changed

  • Move all tests into test folder.

1.1.0 [2017-01-19]

Added

  • Add --ignore-module configuration option.

1.0.1 [2017-11-13]

Added

  • Add Cabal and Documentation testing on Travis CI.

Fixed

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

1.0.0 [2016-11-04]

Added

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

0.0.3 [2016-09-20]

Added

  • --no-module-suffix configuration option.

0.0.2 [2016-02-20]

Added

  • --module-suffix configuration option.

0.0.1 [2016-02-13]

  • tasty-discover initial release.
comments powered byDisqus