| Safe Haskell | None |
|---|---|
| Language | Haskell98 |
Test.Tasty.TH
Description
This module provides TemplateHaskell functions to automatically generate tasty TestTrees from specially named functions. See the README of the package for examples.
Important: due to to the GHC staging restriction, you must put any uses of these functions at the end of the file, or you may get errors due to missing definitions.
Documentation
testGroupGenerator :: ExpQ Source
This function generates a TestTree from functions in the current module.
The test tree is named after the current module.
The following definitions are collected by testGroupGenerator:
- a test_something definition in the current module creates a sub-testGroup with the name "something"
- a prop_something definition in the current module is added as a QuickCheck property named "something"
- a case_something definition leads to a HUnit-Assertion test with the name "something"
Example usage:
prop_example :: Int -> Int -> Bool prop_example a b = a + b == b + a tests ::TestTreetests = $(testGroupGenerator)
defaultMainGenerator :: ExpQ Source
Convenience function that directly generates an IO action that may be used as the
main function. It's just a wrapper that applies defaultMain to the TestTree generated
by testGroupGenerator.
Example usage:
-- properties, test cases, ....
main :: IO ()
main = $(defaultMainGenerator)