简体   繁体   English

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

[英]Haskell Hspec - only run expensive test on command line flag

I want to run an expensive Hspec test only when some flag on the command line is set for stack test . 我只想在命令行中为stack test设置一些标志时才运行昂贵的Hspec stack test I understand that I can use stack test --test-arguments=... but what would I use on the command line and how would I carry out the conditional testing in my Spec.hs ? 我了解可以使用stack test --test-arguments=...但是我将在命令行上使用什么,以及如何在Spec.hs执行条件测试? I can't seem to find a good example elsewhere online. 在网上其他地方,我似乎找不到很好的例子。

EDIT: Is it possible to get a test to be skipped when just running stack test with no skip specified? 编辑:是否有可能仅在运行stack test而不指定跳过的情况下跳过一个测试? Or would this be possible by having another similar specification file with just the expensive test in? 还是通过仅提供昂贵的测试而拥有另一个类似的规格文件,就能做到这一点?

You can use --skip=PATTERN to skip a test. 您可以使用--skip=PATTERN跳过测试。 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 hspecWith (the configSkipPredicate ). 除此之外,如果您不使用自动测试发现,则可以在自己的main检查命令行参数,并为hspecWith设置ConfigconfigSkipPredicate )。

If you want to automatically skip a test without specifying it on the command line you can use a .hspec file, see here . 如果要自动跳过测试而不在命令行上指定,可以使用.hspec文件,请参见此处 The you can override the skip by specifying to match the pattern instead on the command line. 您可以通过在命令行上指定匹配模式来覆盖跳过。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM