Question

Hi I have a scenario where I need to test whether a search service is bringing back the correct results. So my story looks something like this:

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               |

The table under the "Then" section would go on for a while, using different permutations of firstname/lastname criteria followed by nested tables of expected results in the results column. The Examples section would contain a list of possible search criteria passed to the "When" section

Is it possible to have nested tables like this? If not, is there perhaps another method I could use to accomplish the same thing?

Was it helpful?

Solution 2

I wound up re-writing my story as such:

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

I have one @When annotated method for the When and And sentences in the story. The method accepts a firstName, lastName and ExamplesTable parameters using the matcher: "the first name is $firstnamecriteria and the last name is $lastnamecriteria the results should be: $resultsTable"

What I do is I throw the results table into a HashMap key'd by firstName/lastName, I then execute my search function on my service with those same firstName/lastName parameters and throw the results from the service call into another HashMap. In my @Then method, I compare the two HashMap results to see if the expected results from the story match the actual results obtained by the service.

Seems to work ok, and is pretty readable.

OTHER TIPS

There isn't support for that directly as I understand it - though getting ExampleTable values as Parameters will kick in the ParameterConverters - of which an ExampleTable ParameterConverter is setup by default. I'm sure that there is a parsing bug in there.

That said, your "Then" needs to work for all rows of the Examples: section. I'm sure that that is why you were thinking of putting all of them in the Then - you can then pluck out the right one.

Could you do the following:

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     |
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top