Haskell Hspec - 仅 运行 命令行标志的昂贵测试

Haskell Hspec - only run expensive test on command line flag

我想 运行 仅当命令行上的某些标志设置为 stack test 时才进行昂贵的 Hspec 测试。我知道我可以使用 stack test --test-arguments=... 但我会在命令行上使用什么以及我将如何在我的 Spec.hs 中执行条件测试?我似乎无法在网上其他地方找到一个很好的例子。

编辑: 仅 运行ning stack test 且未指定跳过时是否可以跳过测试?或者这是否可以通过另一个类似的规范文件只包含昂贵的测试来实现?

可以使用--skip=PATTERN to skip a test. Other than that, you can check the command line arguments in your own main if you don't use automatic test discovery and set the Config for hspecWithconfigSkipPredicate)。

如果您想自动跳过测试而不在命令行中指定它,您可以使用 .hspec 文件,请参阅 here。您可以通过在命令行上指定匹配模式来覆盖跳过。