简体   繁体   English

运行/排除存在标签的规范

[英]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 . 我知道我可以运行给定的规格some_tagvalue--tag some_tag:value或标签被添加在那里,但没有一个值(默认为true用) --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: 例如:如果我的规格标记有slow: :external_serviceslow: :manual_confirmation slow: :some_other_reasonslow: :some_other_reason (这些只是由名字组成的),我想执行以下操作:

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? 上面的方法不起作用,因为它过滤掉了slow == true而不是!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 ) 我猜想添加两个标记,一个布尔值,另一个包含值(例如: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 并且不会运行标记为slow: :external_service测试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. 请参阅文章的其他选项。

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

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