Java JBehave中的嵌套表

Java JBehave中的嵌套表,java,bdd,jbehave,Java,Bdd,Jbehave,嗨,我有一个场景,我需要测试搜索服务是否返回正确的结果。我的故事是这样的: 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 Scenari

嗨,我有一个场景,我需要测试搜索服务是否返回正确的结果。我的故事是这样的:

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               |
叙述:
以便轻松发现玩家是否已注册忠诚度计划
作为客户服务代表
我想能够通过球员的名字和姓氏搜索注册球员
场景:按名字和姓氏检索玩家信息
给定在数据仓库中注册的玩家以及忠诚1和/或忠诚2计划的某些组合:
|名|姓|市|省|忠诚1 |忠诚2|
|皮特|沃尔特|温尼伯|假|真|
|乔恩|杜威|温尼伯| MB |真|真|
|约翰|杜威| | | |真|真|
|彼得|德瓦尔特| | |真|假|
当指定和标准时
然后,系统使用不区分大小写的“开始于”搜索显示正确的结果,如下所示:
|firstnamecriteria | lastnamecriteria |结果|
|乔| | | |名|姓||
|乔恩·杜维特||
|| | |约翰|杜威||
示例:
|firstnamecriteria | lastnamecriteria|
|乔||
||露水|
|J|D|
“Then”部分下的表将继续使用一段时间,使用firstname/lastname标准的不同排列,然后在results列中使用预期结果的嵌套表。示例部分将包含传递给“When”部分的可能搜索条件的列表


有可能有这样的嵌套表吗?如果没有,我是否可以使用其他方法来完成同样的事情?

据我所知,没有直接支持这一点-尽管获取示例值作为参数将在ParameterConverter中起作用-默认情况下设置了示例ParameterConverter。我确信那里有一个解析错误

这就是说,您的“Then”需要处理所有行的Examples:section。我相信这就是为什么你想把它们都放进这个盒子里,然后你就可以拿出正确的一个

你能做以下几件事吗

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     |
在数据仓库中注册的特定玩家以及忠诚1和/或忠诚2计划的某些组合:
|id |名|姓|市|省|忠诚1 |忠诚2|
|1 |皮特|沃尔特|温尼伯|假|真|
|2 |乔恩|杜威|温尼伯| MB |真|真|
|3 |约翰|杜威| | | |真|真|
|4 |彼得|德瓦尔特| | |真|假|
当指定和标准时
然后,系统使用不区分大小写的“开始于”搜索用户,显示正确的结果
示例:
|firstnamecriteria | lastnamecriteria |用户列表|
|乔| | 2,3|
||露水| 2,3,4|
|J | D | 2,3|

我最终重新写了我的故事:

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
在数据仓库中注册的特定玩家以及忠诚1和/或忠诚2的某些组合:
|名|姓|市|省|忠诚1 |忠诚2|
|皮特|沃尔特|温尼伯|假|真|
|乔恩|杜威|温尼伯| MB |真|真|
|约翰|杜威| | | |真|真|
|彼得|德瓦尔特| | |真|假|
当名为Jon,姓为Dewit时,结果应为:
|名|姓|
|乔恩·杜维特|
名字是dewit,姓是dewit结果应该是:
|名|姓|
|乔恩·杜维特|
|约翰·杜威|
名为de,姓为de。结果应为:
|名|姓|
|乔恩·杜维特|
|约翰·杜威|
|彼得·德瓦尔特|
然后,系统使用不区分大小写的“开始于”搜索显示正确的结果
对于故事中的When和When语句,我有一个
@When
注释方法。该方法使用匹配器接受firstName、lastName和ExamplesTable参数:
“名字是$firstnamecriteria,姓氏是$lastnamecriteria结果应该是:$resultsTable”

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


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

或者指定一个字符串,指向您可以获取和验证的资源(通过url而不是内联获取表)。这也是我想到的解决方案,但是问题是,在这个集成测试中,我的底层数据库为我选择id值,所以我不知道它们是什么。话虽如此,我本可以像你说的那样工作,+1'd