简体   繁体   中英

Run/exclude specs where tag is present

I know I can run specs given some_tag is value with --tag some_tag:value or where tag is added, but doesn't have a value (defaults to true ) with --tag some_tag . I also know I can exclude specs with the above syntax and ~ .

How do I run all specs with a tag present/missing?

For example: If I have specs marked with slow: :external_service , slow: :manual_confirmation or slow: :some_other_reason (these are just made up names), I want to do something like:

rspec --tag ~slow

and run all specs that are not slow.

The above doesn't work since it filters out specs where slow == true instead of !slow.nil?

  • Is there a way to achieve exactly this with or without extra configuration?
  • What is the idiomatic way to do a such thing? I would guess add two tags, one boolean and one containing the value (for example :slow, pending_on: :external_service )

This should help. Basically call

rspec --tag ~slow:external_service

and it won't run tests tagged with slow: :external_service

Exclude with multiple tags can be of some help here.

rspec --tag ~slow:external_service --tag ~slow:manual_confirmation

Refer this article for other options.

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