首页 \ 问答 \ 测试与黄瓜的关联(Testing associations with cucumber)

测试与黄瓜的关联(Testing associations with cucumber)

我是铁杆和黄瓜的新手,我正在尝试测试以下场景

Background:
  Given I have a Group named Group 1
  And I go to the list of groups
  And I have the following users records
    | name    | description | group_id |
    | user 1   |            | 1        |
    | user 2   |            | 1        |
  When I follow Details for Group 1

Scenario: List users from group
  Then I should see "user 1"
  And I should see "user 2"

因此,在我的用户控制器的索引操作中,我列出了group_id中的所有用户,但我不知道如何使用黄瓜进行测试,因为每次运行测试时,我的组名为Group 1都有不同的id。

有谁知道如何解决这个问题?

感谢名单


I'm new to rails and cucumber and I'm trying to test the following scenario

Background:
  Given I have a Group named Group 1
  And I go to the list of groups
  And I have the following users records
    | name    | description | group_id |
    | user 1   |            | 1        |
    | user 2   |            | 1        |
  When I follow Details for Group 1

Scenario: List users from group
  Then I should see "user 1"
  And I should see "user 2"

So, in the index action of my users controller I list all the users from the group_id, but I don't know how to test this using cucumber, because every time I run the test my group named Group 1 has a different id.

Does anyone know how to solve this?

Thanx


原文:https://stackoverflow.com/questions/1603416
更新时间:2022-09-05 12:09

最满意答案

使用LINQ查找的好处:它在.NET 2.0中可用LINQ over Find的好处:与其他序列的一致性; 查询表达式语法等

Find over BinarySearch的好处:列表不需要排序,你只需要相等比较BinarySearch优于Find:BinarySearch是O(log n); 找到是O(n)

查找foreach循环的好处:紧凑而不重复自己foreach循环的好处查找:您要执行的任何其他自定义处理

其中,只有Find vs BinarySearch有任何真正的性能差异。 当然,如果您可以从List<T>更改为Dictionary<TKey,TValue>那么查找元素将分摊O(1)...


Benefit of Find over using LINQ: It's available in .NET 2.0 Benefit of LINQ over Find: consistency with other sequences; query expression syntax etc

Benefit of Find over BinarySearch: The list doesn't have to be sorted, and you only need equality comparison Benefit of BinarySearch over Find: BinarySearch is O(log n); Find is O(n)

Benefit of Find over a foreach loop: compactness and not repeating yourself Benefit of a foreach loop over Find: Any other custom processing you want to perform

Of these, only Find vs BinarySearch has any real performance difference. Of course, if you could change from a List<T> to a Dictionary<TKey,TValue> then finding elements would become amortized O(1) ...

相关问答

更多
  • 如果你不喜欢Ruby,HAML不会帮你。 尽管语法上更加简单,但它与ERB一样使用嵌入式Ruby。 如果你想完全避免你的观点的逻辑,看看像胡须 。 它使用强调逻辑与表示之间更加严格分离的模板化样式(无逻辑视图)。 If you don't like Ruby in your views, HAML is not going to help you. Although syntactically more succint, it uses embedded Ruby just as ERB does. If ...
  • 纯粹的语法便利性和可读性/表现力。 它仍然作为一种方法实施。 所以:如果你认为target[0]对你的场景更明显,方便和可读:使用索引器。 It is purely syntactic convenience and readability / expressiveness. It is still implemented as a method. So: if you think target[0] is more obvious, convenient and readable for your sce ...
  • 那是不可能的。 有关更多信息,请参阅https://github.com/composer/composer/issues/751和https://github.com/composer/composer/issues/2940 。 That's not possible. See https://github.com/composer/composer/issues/751 and https://github.com/composer/composer/issues/2940 for some more ...
  • 使用LINQ查找的好处:它在.NET 2.0中可用LINQ over Find的好处:与其他序列的一致性; 查询表达式语法等 Find over BinarySearch的好处:列表不需要排序,你只需要相等比较BinarySearch优于Find:BinarySearch是O(log n); 找到是O(n) 查找foreach循环的好处:紧凑而不重复自己foreach循环的好处查找:您要执行的任何其他自定义处理 其中,只有Find vs BinarySearch有任何真正的性能差异。 当然,如果您可以从Li ...
  • 许多开发人员使用PSMTabBarControl ,它提供拖放,关闭按钮,可自定义外观等。 Many developers use PSMTabBarControl, which offers drag and drop, close buttons, customisable appearance and the like.
  • 你可以在黄瓜上使用WATIR 。 Infact Facebook使用watir来实现UI自动化。 You can use WATIR with Cucumber. Infact facebook uses watir for its UI automation.
  • 因此,jQuery UI的自动完成控件已成为我自己的目的的有用替代方案: http : //api.jqueryui.com/autocomplete/ So the Autocomplete control from jQuery UI has emerged to be a useful alternative for my own purposes: http://api.jqueryui.com/autocomplete/
  • Emacs的字体锁匹配不限于正则表达式; 你可以使用任何函数作为匹配器,只要它满足某些协议。 有关更多详细信息,请查看变量font-lock-keywords 。 Ch v font-lock-keywords Emacs' font-lock matching is not restricted to regular-expression; you can use any function as matcher provided it satisfies certain protocol. Take a ...
  • 上面的帖子实际上是我的,不太清楚发生了什么,但如果你想看看我的建议,我可以给你额外的资源。 以下是我发现非常有用的众多入门资源。 教程 快速开始 ZK Essentials (推荐阅读) 文档索引 我还会说,我将它与许多框架集成在一起,并且工作完美无瑕。 如果您喜欢JSF方法,我也喜欢使用ICEfaces,但是,这可能会变得相当复杂! 就我个人而言,我更喜欢ZK的方法,各自为政。 希望这可以帮助! The post above is actually mine, not too sure what happ ...
  • 对于大多数实际用途, std::initializer_list提供了一个好处:初始化任意类型对象的能力。 缺乏缩小是很好的,但与简单的方便性相比,绝对相形见绌 : std::vector foo { 1, 2, 3, 4}; 而不是: std::vector foo; foo.push_back(1); foo.push_back(2); foo.push_back(3); foo.push_back(4); ...或者产生的大量黑客,主要是基于滥用逗号运算符的重载来获得如下语法: ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。