{"id":16907198,"url":"https://github.com/minad/tasty-auto","last_synced_at":"2025-09-05T00:47:51.047Z","repository":{"id":56879902,"uuid":"79872769","full_name":"minad/tasty-auto","owner":"minad","description":"Deprecated: Auto discovery for the Tasty test framework, use tasty-discover instead","archived":false,"fork":false,"pushed_at":"2018-04-30T10:41:22.000Z","size":29,"stargazers_count":6,"open_issues_count":0,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-05-02T00:32:47.733Z","etag":null,"topics":["auto-discovery","haskell","testing"],"latest_commit_sha":null,"homepage":"https://github.com/lwm/tasty-discover","language":"Haskell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/minad.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-01-24T02:55:47.000Z","updated_at":"2019-12-05T06:35:13.000Z","dependencies_parsed_at":"2022-08-20T23:40:14.423Z","dependency_job_id":null,"html_url":"https://github.com/minad/tasty-auto","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/minad%2Ftasty-auto","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/minad%2Ftasty-auto/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/minad%2Ftasty-auto/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/minad%2Ftasty-auto/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/minad","download_url":"https://codeload.github.com/minad/tasty-auto/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248432936,"owners_count":21102470,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["auto-discovery","haskell","testing"],"created_at":"2024-10-13T18:46:29.481Z","updated_at":"2025-04-11T15:41:02.599Z","avatar_url":"https://github.com/minad.png","language":"Haskell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# tasty-auto: Simple auto discovery for Tasty\n\n[![Hackage](https://img.shields.io/hackage/v/tasty-auto.svg)](https://hackage.haskell.org/package/tasty-auto)\n[![Build Status](https://secure.travis-ci.org/minad/tasty-auto.png?branch=master)](http://travis-ci.org/minad/tasty-auto)\n\nThis package provides auto discovery for the tasty test framework.\n\n* Install tasty-auto (using cabal or stack)\n\n* Create a file test/test.hs\n\n``` haskell\n-- test/test.hs\n{-# OPTIONS_GHC -F -pgmF tasty-auto #-}\n```\n\n* Put your tests in files with the suffix `*Test.hs` or `*Spec.hs`. Functions\nwith the following prefixes are automatically discovered:\n\n* `prop_` for QuickCheck properties\n* `scprop_` for SmallCheck properties\n* `case_` for HUnit test cases (overloaded for `IO ()`, `IO String` and `(String -\u003e IO ()) -\u003e IO`)\n* `spec_` for Hspec specifications\n* `test_` for Tasty TestTrees (overloaded for `TestTree`, `[TestTree]`, `IO TestTree` and `IO [TestTree]`)\n\n## Examples\n\n### QuickCheck\n\n``` haskell\n-- test/PropTest.hs\nmodule PropTest where\n\nprop_Addition_is_commutative :: Int -\u003e Int -\u003e Bool\nprop_Addition_is_commutative a b = a + b == b + a\n```\n\n### HUnit\n\n``` haskell\n-- test/CaseTest.hs\nmodule CaseTest where\n\nimport Test.Tasty.HUnit\n\ncase_List_comparison_with_different_length :: IO ()\ncase_List_comparison_with_different_length = [1, 2, 3] `compare` [1,2] @?= GT\n```\n\n### Hspec\n\n``` haskell\n-- test/TestSpec.hs\nmodule TestSpec where\n\nimport Test.Tasty.Hspec\n\nspec_Prelude :: Spec\nspec_Prelude = do\n  describe \"Prelude.head\" $ do\n    it \"returns the first element of a list\" $ do\n      head [23 ..] `shouldBe` (23 :: Int)\n```\n\n### Test trees\n\n``` haskell\n-- test/TreeTest.hs\n{-# LANGUAGE ScopedTypeVariables #-}\nmodule TreeTest where\n\nimport Test.Tasty\nimport Test.Tasty.QuickCheck\nimport Test.Tasty.HUnit\n\ntest_Addition :: TestTree\ntest_Addition = testProperty \"Addition commutes\" $ \\(a :: Int) (b :: Int) -\u003e a + b == b + a\n\ntest_Multiplication :: [TestTree]\ntest_Multiplication =\n  [ testProperty \"Multiplication commutes\" $ \\(a :: Int) (b :: Int) -\u003e a * b == b * a\n  , testProperty \"One is identity\" $ \\(a :: Int) -\u003e a * 1 == a\n  ]\n\ntest_Generate_Tree :: IO TestTree\ntest_Generate_Tree = do\n  input \u003c- pure \"Some input\"\n  pure $ testCase input $ pure ()\n\ntest_Generate_Trees :: IO [TestTree]\ntest_Generate_Trees = do\n  inputs \u003c- pure [\"First input\", \"Second input\"]\n  pure $ map (\\s -\u003e testCase s $ pure ()) inputs\n```\n\n## Configuration options\n\nYou can add tasty ingredients with the `-optF` option:\n\n``` haskell\n-- test/test.hs\n{-# OPTIONS_GHC -F -pgmF tasty-auto -optF --ingredient=Test.Tasty.Runners.Html.htmlRunner -optF --ingredient=Test.Tasty.Runners.AntXML.antXMLRunner #-}\n```\n\nIt is possible to configure the name of the generated module, if you want to import the module somewhere.\n\n``` haskell\n-- test/AutoTests.hs\n{-# OPTIONS_GHC -F -pgmF tasty-auto -optF --module=AutoTests #-}\n```\n\n## Generated code\n\nThe generated code of the preprocessor looks like this:\n\n``` haskell\n{-# LINE 1 \"test/test.hs\" #-}\n{-# LANGUAGE FlexibleInstances #-}\nmodule Main (main, ingredients, tests) where\nimport Prelude\nimport qualified Test.Tasty as T\nimport qualified Test.Tasty.Ingredients as T\nimport qualified Test.Tasty.HUnit as HU\nimport qualified Test.Tasty.QuickCheck as QC\nimport qualified Test.Tasty.SmallCheck as SC\nimport qualified Test.Tasty.Hspec as HS\nimport qualified CaseTest\nimport qualified SCPropTest\nimport qualified TreeTest\nimport qualified PropTest\nimport qualified TestSpec\nimport qualified SubMod.PropTest\nclass TestCase a where testCase :: String -\u003e a -\u003e IO T.TestTree\ninstance TestCase (IO ())                      where testCase n = pure . HU.testCase      n\ninstance TestCase (IO String)                  where testCase n = pure . HU.testCaseInfo  n\ninstance TestCase ((String -\u003e IO ()) -\u003e IO ()) where testCase n = pure . HU.testCaseSteps n\nclass TestGroup a where testGroup :: String -\u003e a -\u003e IO T.TestTree\ninstance TestGroup T.TestTree        where testGroup _ a = pure a\ninstance TestGroup [T.TestTree]      where testGroup n a = pure $ T.testGroup n a\ninstance TestGroup (IO T.TestTree)   where testGroup _ a = a\ninstance TestGroup (IO [T.TestTree]) where testGroup n a = T.testGroup n \u003c$\u003e a\ntests :: IO T.TestTree\ntests = do\n  t0 \u003c- testCase \"List comparison with different length\" CaseTest.case_List_comparison_with_different_length\n  t1 \u003c- pure $ SC.testProperty \"sort reverse\" SCPropTest.scprop_sort_reverse\n  t2 \u003c- testGroup \"Addition\" TreeTest.test_Addition\n  t3 \u003c- testGroup \"Multiplication\" TreeTest.test_Multiplication\n  t4 \u003c- testGroup \"Generate Tree\" TreeTest.test_Generate_Tree\n  t5 \u003c- testGroup \"Generate Trees\" TreeTest.test_Generate_Trees\n  t6 \u003c- pure $ QC.testProperty \"Addition is commutative\" PropTest.prop_Addition_is_commutative\n  t7 \u003c- HS.testSpec \"Prelude\" TestSpec.spec_Prelude\n  t8 \u003c- pure $ QC.testProperty \"Addition is associative\" SubMod.PropTest.prop_Addition_is_associative\n  pure $ T.testGroup \"test/test.hs\" [t0,t1,t2,t3,t4,t5,t6,t7,t8]\ningredients :: [T.Ingredient]\ningredients = T.defaultIngredients\nmain :: IO ()\nmain = tests \u003e\u003e= T.defaultMainWithIngredients ingredients\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fminad%2Ftasty-auto","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fminad%2Ftasty-auto","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fminad%2Ftasty-auto/lists"}