Haskell Test.Framework指定从命令行运行的测试数

时间:2016-03-23 23:46:43

标签: unit-testing haskell testing quickcheck test-framework

这个documentation意味着可以使用命令行参数运行Test.Framework。有一个函数defaultMain :: [Test] -> IO (),但函数defaultMainWithOpts :: [Test] -> RunnerOptions -> IO ()

  

defaultMain的一个版本,它允许您忽略命令行参数,而使用明确的RunnerOptions集。

我找不到有关如何传递命令行参数的文档,而无法识别的选项的错误消息只显示“无法识别的选项”。所以我的问题是如何在运行cabal test

时传递从命令行运行的测试用例数

1 个答案:

答案 0 :(得分:1)

defaultMainWithOpts不适用于命令行:它忽略并禁止所有命令行选项。要在命令行上进行测试,您应该使用defaultMain,而--help会告诉您所有可用的选项,例如:

Usage: cc-test [OPTIONS]
                   --help                                       show this help message
  -j NUMBER        --threads=NUMBER                             number of threads to use to run tests
                   --test-seed=NUMBER|random                    default seed for test random number generator
  -a NUMBER        --maximum-generated-tests=NUMBER             how many automated tests something like QuickCheck should try, by default
                   --maximum-unsuitable-generated-tests=NUMBER  how many unsuitable candidate tests something like QuickCheck should endure before giving up, by default
  -s NUMBER        --maximum-test-size=NUMBER                   to what size something like QuickCheck should test the properties, by default
  -d NUMBER        --maximum-test-depth=NUMBER                  to what depth something like SmallCheck should test the properties, by default
  -o NUMBER        --timeout=NUMBER                             how many seconds a test should be run for before giving up, by default
                   --no-timeout                                 specifies that tests should be run without a timeout, by default
  -l               --list-tests                                 list available tests but don't run any; useful to guide subsequent --select-tests
  -t TEST-PATTERN  --select-tests=TEST-PATTERN                  only tests that match at least one glob pattern given by an instance of this argument will be run
                   --jxml=FILE                                  write a JUnit XML summary of the output to FILE
                   --jxml-nested                                use nested testsuites to represent groups in JUnit XML (not standards compliant)
                   --plain                                      do not use any ANSI terminal features to display the test run
                   --color                                      use ANSI terminal features to display the test run
                   --hide-successes                             hide sucessful tests, and only show failures