我想在Haskell模块中编写自己的测试用例。让我们说我做了一个“范围”模块。我可能想查一下:
(range 1 2) + (range 3 5) == (range 1 5)
(range 1 4) + empty == (range 1 4)
等
我想将这些测试放在模块中,也许还有一些方法可以使用编译器标志打开/关闭它们。
我目前对一些为我生成测试用例的框架并不感兴趣,我很高兴自己这样做。
答案 0 :(得分:2)
为什么不尝试新的Tasty热度。美味可以与cabal集成,用于集成建筑/测试。
import Test.Tasty
import Test.Tasty.HUnit
import My.Range.Module
main = defaultMain unitTests
unitTests = testGroup "Unit tests" [
testCase "Adding Continuous Ranges" $
(range 1 2) + (range 3 5) @?= (range 1 5),
testCase "Adding an empty Range" $
(range 1 4) + empty @?= (range 1 4)]
有命令行选项
% ./test --help
Mmm... tasty test suite
Usage: ex [-p|--pattern ARG] [-l|--list-tests] [-j|--num-threads ARG]
[-q|--quiet] [--hide-successes] [--smallcheck-depth ARG]
[--quickcheck-tests ARG] [--quickcheck-replay ARG]
[--quickcheck-max-size ARG] [--quickcheck-max-ratio ARG]
Available options:
-h,--help Show this help text
-p,--pattern ARG Select only tests that match pattern
-l,--list-tests Do not run the tests; just print their names
-j,--num-threads ARG Number of threads to use for tests execution
-q,--quiet Do not produce any output; indicate success only by
the exit code
--hide-successes Do not print tests that passed successfully
--smallcheck-depth ARG Depth to use for smallcheck tests
--quickcheck-tests ARG Number of test cases for QuickCheck to generate
--quickcheck-replay ARG Replay token to use for replaying a previous test run
--quickcheck-max-size ARG
Size of the biggest test cases quickcheck generates
--quickcheck-max-ratio ARG
Maximum number of discared tests per successful test
before giving up
您可以使用--pattern
选项仅选择要运行的特定测试