我正在为我们的企业开发一个自动支付处理服务。我们正在尝试实现spec flow,我们已经成功地为1WHEN条件实现了这一点
Scenario Outline: Stub matches NEXT oldest outstanding bill
Given I have a group with the following bills:
| Id | Due Date | Status | Amount Due |
| Bill A | 9/14/2011 | <Oldest Bill Status> | 1100.00 |
| Bill B | 10/14/2011 | Unpaid | 1200.00 |
| Bill C | 11/14/2011 | Unpaid | 1300.00 |
When a stub is received that matches 'Bill B'
And the Payment Amount is <Payment Amount>
Then the allocation result should <Allocation Result>
And Review should <Review>
Examples:
| Oldest Bill Status | Allocation Result | Review | Payment Amount |
| Reconciled | Allocate to Bill | not required | 1200.00 |
[When(@"a stub is received that matches '(.*)'")]
public void WhenAStubIsReceivedThatMatches(string billKeyName)
{
// Method
}在执行result步骤之前,我不确定如何更改钩子来处理这两种情况。
发布于 2012-01-28 16:05:08
最佳实践是有一条When语句。
一些选项包括:
When a stub is received that matches 'Bill B' for <Payment Amount>因此:
[When(@"a stub is received that matches '(.*)' for ([\d\.]*)")]
public void WhenAStubIsReceivedThatMatches(string billKeyName, decimal amount)
{
// create stub and "recieve" it
}或
Given ...etc...
And I have a stub is received that matches 'Bill B' for <Payment Amount>
When I receive the stub..。因为存根本身不是被测试的对象,它是背景数据,可以明智地创建为给定的一部分。
发布于 2011-12-14 20:53:43
禁止使用多个When-子句...我认为你可以理解(并解释)为什么,因为你问了这个问题。很难把几个动作放在一起,因为它们相互依赖。
试着用一个简单的When-子句来编写您的规范,而不是编写不同的场景来描述您交互的不同方式。
因此,对于您的场景,如果您愿意,尝试找出从给定状态到当时状态发生的重要状态转换是什么。
这是我发现的一个小诀窍,对编写场景很有用
几周前,我在Gjoko Adzic的课程上学到了很多这样的技巧。Read about it here
https://stackoverflow.com/questions/8495323
复制相似问题