如何 运行 使用 Stack 和 Haskell Test.Framework 进行单独测试?
How to run an individual test with Stack and Haskell Test.Framework?
我正在克隆 following repository 并通过在末尾添加对 stack.yaml
进行一项更改:
docker:
enable: true
运行 haskoin-core
的所有测试我正在使用
stack test haskoin-core:test-haskoin-core
我想做的只是运行一个测试。如果这是 HSpec
(事实并非如此),我会 运行宁 :
stack test --test-arguments -m "Network.Haskoin.Network.Units"
现在我能做的就是修改文件 haskcoin-core/test/Main.hs
并注释掉所有我不想 运行 的测试。但是你知道 - 应该有一个更简单的方法来 运行 它只用命令行参数。 (改变文件系统再次影响 Haskell 的整个功能粒度)。
我也愿意以某种方式 运行 将其与 stack ghci
结合起来。
我的问题是:如何 运行 使用 Stack 和 Haskell Test.Framework 进行个人测试?
感谢@sjakobi 的回答。
过程是 - 列出可用的测试命令:
stack test --test-arguments "--help" haskoin-core:test-haskoin-core
结果如下:
haskoin-core-0.4.2: test (suite: test-haskoin-core, args: --help)
Usage: test-haskoin-core [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
Test suite failure for package haskoin-core-0.4.2
test-haskoin-core: exited with: ExitFailure 1
Logs printed to console
由此我们可以构建一个命令来列出测试:
stack test --test-arguments "--list-tests" haskoin-core:test-haskoin-core
从那里我们可以使用此命令对特定测试进行 glob
stack test --test-arguments=--select-tests=Bloom*Filter haskoin-core:test-haskoin-core
请注意 *
代替了 space,似乎有 some discussion 关于如何在这种情况下处理 space。
现在选择我们想要的测试 运行:
haskoin-core-0.4.2: test (suite: test-haskoin-core, args: --select-tests=Bloom*Filter)
Binary encoding and decoding of bloom types:
BloomFilter: [OK, passed 100 tests]
Bloom Filters:
Bloom Filter Vector 1: [OK]
Bloom Filter Vector 2: [OK]
Bloom Filter Vector 3: [OK]
Properties Test Cases Total
Passed 1 3 4
Failed 0 0 0
Total 1 3 4
截至 2019 年年中,我认为 stack
已经改变。
选项见--help
:
stack test --test-arguments "--help"
做一个 --dry-run
看看会有什么测试 运行:
stack test --test-arguments "--dry-run"
Select 使用 --match
进行测试。请注意,这声称 glob 模式会起作用,但它们对我来说似乎不起作用:
stack test --test-arguments "--match=foobar"
AFAICT,"foobar"
被解释为一团 *foobar*
,但我不能明确说明。
我正在克隆 following repository 并通过在末尾添加对 stack.yaml
进行一项更改:
docker:
enable: true
运行 haskoin-core
的所有测试我正在使用
stack test haskoin-core:test-haskoin-core
我想做的只是运行一个测试。如果这是 HSpec
(事实并非如此),我会 运行宁
stack test --test-arguments -m "Network.Haskoin.Network.Units"
现在我能做的就是修改文件 haskcoin-core/test/Main.hs
并注释掉所有我不想 运行 的测试。但是你知道 - 应该有一个更简单的方法来 运行 它只用命令行参数。 (改变文件系统再次影响 Haskell 的整个功能粒度)。
我也愿意以某种方式 运行 将其与 stack ghci
结合起来。
我的问题是:如何 运行 使用 Stack 和 Haskell Test.Framework 进行个人测试?
感谢@sjakobi 的回答。
过程是 - 列出可用的测试命令:
stack test --test-arguments "--help" haskoin-core:test-haskoin-core
结果如下:
haskoin-core-0.4.2: test (suite: test-haskoin-core, args: --help)
Usage: test-haskoin-core [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
Test suite failure for package haskoin-core-0.4.2
test-haskoin-core: exited with: ExitFailure 1
Logs printed to console
由此我们可以构建一个命令来列出测试:
stack test --test-arguments "--list-tests" haskoin-core:test-haskoin-core
从那里我们可以使用此命令对特定测试进行 glob
stack test --test-arguments=--select-tests=Bloom*Filter haskoin-core:test-haskoin-core
请注意 *
代替了 space,似乎有 some discussion 关于如何在这种情况下处理 space。
现在选择我们想要的测试 运行:
haskoin-core-0.4.2: test (suite: test-haskoin-core, args: --select-tests=Bloom*Filter)
Binary encoding and decoding of bloom types:
BloomFilter: [OK, passed 100 tests]
Bloom Filters:
Bloom Filter Vector 1: [OK]
Bloom Filter Vector 2: [OK]
Bloom Filter Vector 3: [OK]
Properties Test Cases Total
Passed 1 3 4
Failed 0 0 0
Total 1 3 4
截至 2019 年年中,我认为 stack
已经改变。
选项见
--help
:stack test --test-arguments "--help"
做一个
--dry-run
看看会有什么测试 运行:stack test --test-arguments "--dry-run"
Select 使用
--match
进行测试。请注意,这声称 glob 模式会起作用,但它们对我来说似乎不起作用:stack test --test-arguments "--match=foobar"
AFAICT,"foobar"
被解释为一团 *foobar*
,但我不能明确说明。