简体   繁体   English

常用哪些黄瓜标签? 我“可以” /“应该”使用“如何” /“以何种方式”?

[英]What Cucumber tags are commonly used? “How”/“In which ways” I “could”/“should” use those?

I am using Ruby on Rails 3.2.2 and Cucumber with the cucumber-rails gem. 我在cucumber-rails gem中使用Ruby on Rails 3.2.2和Cucumber。 I would like to know what Cucumber tags are commonly used throughout an application or at least on what criteria I should think about those so to make tags "efficient"/"useful". 我想知道在整个应用程序中通常使用哪种Cucumber标签,或者至少我应该考虑哪些标准才能使标签“有效” /“有用”。 More, I would like to know "how"/"in which ways" I "could"/"should" use Cucumber tags. 另外,我想知道“我”“应该” /“应该”以哪种方式使用黄瓜标签。

Tags are most commonly used to select or exclude certain tests from running. 标签最常用于选择或排除某些测试。 Your particular situation will dictate what 'groups' of tests are useful to run or not run for a particular test run, but some common examples could be: 您的具体情况将决定哪些“测试组”对于特定测试运行对于运行或不运行是有用的,但是一些常见的示例可能是:

  • @slow - indicates a test that takes a long time to run, you might want to exclude this from most test runs and only run it on an overnight build so that developers don't have to wait for it every time. @slow表示需要花费很长时间才能运行的测试,您可能希望将其从大多数测试运行中排除,而仅在通宵的构建中运行,这样开发人员不必每次都等待它。
  • @wip - indicates that this test exercises unfinished functionality, so it would be expected to fail while the feature is in development (and when it's done, the @wip tag would be removed). @wip表示该测试行使未完成的功能,因此在该功能处于开发阶段时(如果完成,将删除@wip标记)可能会@wip This has special significance in Cucumber as it will return a non-zero exit code if any @wip tests actually pass 这在Cucumber中具有特殊意义,因为如果任何@wip测试实际通过,它将返回一个非零的退出代码。
  • @release_x , @sprint_y , @version_z etc. Many teams tag each test with information about which release/sprint/version contains it, so that they can run a minimal suite of tests during development. @release_x@sprint_y@version_z等很多球队标记的信息每次测试哪个版本/冲刺/版本包含它,以便他们可以在开发期间运行测试最小套件。 Generally the same as the @wip tag except that they stay attached to the test so they always know when a particular feature was introduced. 通常与@wip标记相同,不同之处在于它们保持附着在测试中,因此它们始终知道何时引入了特定功能。
  • @payments , @search , @seo etc. Basically any logical grouping of tests that isn't already expressed by the organisation of your feature files. @payments@search@seo等,基本上那是不是已经被你的特性文件的组织表示任何测试逻辑分组。 Commonly used when a test relates to a cross-cutting concern, or when your project is divided into components along different lines to your feature files. 通常在测试涉及跨领域关注时,或者在您的项目按照功能文件的不同行分成多个组件时使用。

Tags are also used to fire hooks - bits of code which can run before, after, or 'around' tests with particular tags. 标签还用于触发挂钩-可以在使用特定标签进行测试之前,之后或“前后”运行的代码位。 Some examples of this are: 例如:

  • @javascript - indicates that a test needs Javascript support, so the hook can switch from an HTTP-only driver to one with JS support. @javascript表示测试需要Javascript支持,因此该钩子可以从仅HTTP驱动程序切换为具有JS支持的驱动程序。 Capybara goes one step further by automatically switching to a driver named after the tag, if one is found (so you could use eg @desktop , @mobile , @tablet drivers) 如果发现了@desktop@mobile会自动切换到以该标签命名的驱动程序,从而@desktop (因此,您可以使用@desktop@mobile@tablet驱动程序)
  • @logged_in - indicates that the test needs to run in the context of a logged-in user, this sometimes makes sense to express with a tag, although a Background section would be more commonly used @logged_in指示测试需要在已登录用户的上下文中运行,尽管使用“背景”部分会更常用,但这有时可以用标记来表达

Additionally, tags can be used just for informational purposes. 此外,标签仅可用于提供信息。 I've seen teams tag tests with the related issue number, author, developer, amongst other things, many of which can be useful (but many of which duplicate information which is easily found in source control, so I'd caution against that). 我见过团队用相关的问题编号,作者,开发人员来标记测试,其中许多都是有用的(但是其中许多重复的信息很容易在源代码管理中找到,因此我要特别注意) 。

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

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