测试与黄瓜的关联(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
最满意答案
使用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 aDictionary<TKey,TValue>
then finding elements would become amortized O(1) ...
相关问答
更多-
ERB的替代品(Alternatives to ERB)[2023-10-03]
如果你不喜欢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 ... -
索引器有什么好处?(What are the benefits of an indexer?)[2022-02-17]
纯粹的语法便利性和可读性/表现力。 它仍然作为一种方法实施。 所以:如果你认为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 ...
-
NSTabView替代品(NSTabView alternatives)[2021-09-19]
许多开发人员使用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/
-
font-lock的替代品(Alternatives to font-lock)[2023-07-04]
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 ... -
SmartGWT替代品[已关闭](SmartGWT alternatives [closed])[2022-03-19]
上面的帖子实际上是我的,不太清楚发生了什么,但如果你想看看我的建议,我可以给你额外的资源。 以下是我发现非常有用的众多入门资源。 教程 快速开始 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); ...或者产生的大量黑客,主要是基于滥用逗号运算符的重载来获得如下语法: ...