0

嗨,我有一个场景,我需要测试搜索服务是否带回了正确的结果。所以我的故事看起来是这样的:

Narrative:
In order to easily discover if a player is registered in a loyalty program
As a customer service representative
I want to be able to search for registered players by player first and last name

Scenario: Retrieve Player information by First and Last Name

Given players registered in the Data Warehouse and some combination of Loyalty1 and/or Loyalty2 programs:
|first name|last name|city     |province|loyalty1 |loyalty2|
|Pete      |Walter   |Winnipeg |<null>  |false    |true    |
|Jon       |Dewit    |Winnipeg |MB      |true     |true    |
|John      |Dewit    |<null>   |<null>  |true     |true    |
|Peter     |Dewalt   |<null>   |<null>  |true     |false   |

When the <firstnamecriteria> and <lastnamecriteria> criteria are specified

Then the system displays the correct results, using a case-insensitive "begins with" search as follows:
|firstnamecriteria|lastnamecriteria|results               |
|Jo               |                ||first name|last name||
|                 |                ||Jon       |Dewit    ||
|                 |                ||John      |Dewit    ||

Examples:
|firstnamecriteria|lastnamecriteria|
|Jo               |                |
|                 |Dew             |
|J                |D               |

“然后”部分下的表格将持续一段时间,使用名字/姓氏标准的不同排列,然后是结果列中预期结果的嵌套表格。示例部分将包含传递给“时间”部分的可能搜索条件列表

有可能有这样的嵌套表吗?如果没有,是否有另一种方法可以用来完成同样的事情?

4

2 回答 2

1

据我了解,不直接支持这一点 - 尽管将 ExampleTable 值作为参数获取将在 ParameterConverters 中启动 - 默认情况下设置 ExampleTable ParameterConverter。我确定那里有一个解析错误。

也就是说,您的“然后”需要适用于示例:部分的所有行。我敢肯定这就是为什么你想把它们都放在 Then 中 - 然后你可以挑选出正确的一个。

你能做到以下几点:

Given players registered in the Data Warehouse and some combination of Loyalty1 and/or Loyalty2 programs:
|id|first name|last name|city     |province|loyalty1 |loyalty2|
|1 |Pete      |Walter   |Winnipeg |<null>  |false    |true    |
|2 |Jon       |Dewit    |Winnipeg |MB      |true     |true    |
|3 |John      |Dewit    |<null>   |<null>  |true     |true    |
|4 |Peter     |Dewalt   |<null>   |<null>  |true     |false   |
When the <firstnamecriteria> and <lastnamecriteria> criteria are specified
Then the system displays the correct results, using a case-insensitive "begins with" search with users <userlist>

Examples:
|firstnamecriteria|lastnamecriteria|userlist|
|Jo               |                |2,3     |
|                 |Dew             |2,3,4   |
|J                |D               |2,3     |
于 2012-03-07T20:28:32.810 回答
0

我最终重写了我的故事:

Given players registered in the Data Warehouse and some combination of Loyalty1 and/or Loyalty2 :
|first name|last name|city     |province|loyalty1 |loyalty2|
|Pete      |Walter   |Winnipeg |<null>  |false    |true    |
|Jon       |Dewit    |Winnipeg |MB      |true     |true    |
|John      |Dewit    |<null>   |<null>  |true     |true    |
|Peter     |Dewalt   |<null>   |<null>  |true     |false   |

When the first name is Jon and the last name is Dewit the results should be:
|first name|last name|
|Jon       |Dewit    |

And the first name is <null> and the last name is dewit the results should be:
|first name|last name|
|Jon       |Dewit    |
|John      |Dewit    |

And the first name is <null> and the last name is de the results should be:
|first name|last name|
|Jon       |Dewit    |
|John      |Dewit    |
|Peter     |Dewalt   |

Then the system displays the correct results, using a case-insensitive "begins with" search

@When对故事中的When和And句子有一种注释方法。该方法使用匹配器接受 firstName、lastName 和 ExamplesTable 参数:"the first name is $firstnamecriteria and the last name is $lastnamecriteria the results should be: $resultsTable"

我所做的是将结果表放入由 firstName/lastName 指定的 HashMap 键中,然后使用相同的 firstName/lastName 参数在我的服务上执行搜索功能,并将服务调用的结果放入另一个 HashMap。在我的@Then方法中,我比较了两个 HashMap 结果,以查看故事的预期结果是否与服务获得的实际结果相匹配。

似乎工作正常,而且可读性很好。

于 2012-03-08T20:30:52.367 回答