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.