2012-03-07 5 views
0

Привет, У меня есть сценарий, где мне нужно проверить, возвращает ли служба поиска правильные результаты. Так что моя история выглядит примерно так:Вложенные таблицы в 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 

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    | 

В таблице под «Тогда» раздел будет продолжаться некоторое время, используя различные перестановки ПгвЬЫата/LastName критериев с последующих вложенными таблицами ожидаемых результатов в столбце результатов. Раздел «Примеры» содержит список возможных критериев поиска, переданных в раздел «Когда»

Возможно ли иметь вложенные таблицы, подобные этому? Если нет, есть ли другой способ, который я мог бы использовать для достижения того же самого?

ответ

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 аннотированный метод когда и и предложениях в истории , Метод принимает параметры firstName, lastName и ExamplesTable с помощью сопоставления: "the first name is $firstnamecriteria and the last name is $lastnamecriteria the results should be: $resultsTable"

Что я делаю, это то, те же параметры firstName/lastName и выкидывать результаты вызова службы в другой HashMap. В моем методе @Then я сравниваю два результата HashMap, чтобы увидеть, соответствуют ли ожидаемые результаты истории истории фактическим результатам, полученным службой.

Кажется, что все в порядке и довольно читаемо.

1

Это не поддерживается так, как я понимаю, хотя и получаю значения ExampleTable, поскольку параметры будут запускаться в ParameterConverters, из которых по умолчанию установлен параметр ParameterConverter ExampleTable. Я уверен, что там есть ошибка синтаксического анализа.

Тем не менее, ваше «то» должно работать для всех строк раздела «Примеры:». Я уверен, что именно поэтому вы думали о том, чтобы положить их в «Затем», - тогда вы сможете вырвать правильный.

Не могли бы вы сделать следующее:

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  | 
+0

или указать строку, указывающую на ресурс, который вы можете получить и проверить (получение таблицы по URL-адресу, а не встроенному). –

+0

Это было решение, которое я придумал, однако проблема заключалась в том, что моя базовая БД в этих тестах интеграции значение id для меня, поэтому я не знаю, какими они были главой времени. Сказав это, я мог бы заставить его работать, как вы сказали, + 1'd для этого – ThaDon