cucumber repeat substeps in a feature file

2019-09-12 09:04发布

问题:

I have to run a feature file with multiple cases in a single login. For ex:

Scenario: check total When user logs in with "username" and "password" And user checks for "" on "" And user checks for "" on ""

Examples:

| username | password | amount1 | date1 |amount2|date2|... some 20 entries..

I need to check for amount on date in a single login,while in my scenario it is login each time for every entry in data table.How do I achieve it?

Instead I want something like this:
When user logs in with "username" and "password"

Examples:
|username|password| ..use it only once And user checks for "amount" on "date"

Examples:

|amount|date|....loop over 20 times

回答1:

After some research,I have found an answer to this.Just give a datatable after that step,and take datatable as argument in the corresponding java method and iterate over it.