简体   繁体   中英

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 . 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 ? 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? 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. 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 ).

If you want to automatically skip a test without specifying it on the command line you can use a .hspec file, see here . The you can override the skip by specifying to match the pattern instead on the command line.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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