How to re-run the outline of a cucumber script with different parameters?

I have a cucumber script script for testing a web service that looks like:

Scenario Outline: Check the limit functionality When I GET "/api/activity-schedule-items.xml" with parameters {<filter>} Then the xml attribute "total-count" is "<count>" Scenarios: | filter | count | | 'limit' => 0 | 0 | | 'limit' => 2 | 2 | | 'limit' => 2 | 2 | | 'limit' => -1 | 15 | 

which works fine, however I want to re-run the same script and scripts for each of our web services. Basically, I would like to add another Scenarios block, for example:

 Scenario Outline: Check the limit functionality When I GET "<api>" with parameters {<filter>} Then the xml attribute "total-count" is "<count>" Scenarios: | filter | count | | 'limit' => 0 | 0 | | 'limit' => 2 | 2 | | 'limit' => 2 | 2 | | 'limit' => -1 | 15 | Scenarios: | api | | /api/activity-schedule-items.xml | | /api/activity-schedules.xml | | /api/tasks.xml | 

and have a cucumber, make a cross join between two tables.

It would be even better to specify an api table so that it applies to all scripts in this function.

Is there any way to realize this in cucumbers?

+2
source share
2 answers

Cucumber does not support script iteration. Your only β€œnative” option really is to manually perform cross-connect.

Where I work, we have a very similar situation, and we run Cucumber 8 times at times, and then combine the results, which require a lot of plumbing, and the performance is terrible.

I recently collected a gem designed to solve this problem, it is very rude, and I personally have not used it in anger, but it can help you take a look at https://github.com/jmerrifield/cuke_iterations . I would be happy to help you get up and work with him if you think this might be helpful.

+4
source

you can use a table, but the table only iterates one step by the number of rows, so I converted two steps into one. The code is as follows:

 Scenario Outline: Check the limit functionality When I GET api with following parameters Then the xml attribute "total-count" is as follows | 'limit' => 0 | 0 | <api> | | 'limit' => 2 | 2 | <api> | | 'limit' => 2 | 2 | <api> | | 'limit' => -1 | 15 | <api> | Examples: | api | |/api/activity-schedule-items.xml | |/api/activity-schedules.xml | |/api/tasks.xml | 

Secondly, this is the usual way that you could use

 Scenario Outline: Check the limit functionality When I GET "<api>" with parameters {<filter>} Then the xml attribute "total-count" is "<count>" Examples: | filter | count | api | | 'limit' => 0 | 0 | /api/activity-schedule-items.xml | | 'limit' => 2 | 2 | /api/activity-schedule-items.xml | | 'limit' => 2 | 2 | /api/activity-schedule-items.xml | | 'limit' => -1 | 15 | /api/activity-schedule-items.xml | | 'limit' => 0 | 0 | /api/activity-schedules.xml | | 'limit' => 2 | 2 | /api/activity-schedules.xml | | 'limit' => 2 | 2 | /api/activity-schedules.xml | | 'limit' => -1 | 15 | /api/activity-schedules.xml | | 'limit' => 0 | 0 | /api/tasks.xml | | 'limit' => 2 | 2 | /api/tasks.xml | | 'limit' => 2 | 2 | /api/tasks.xml | | 'limit' => -1 | 15 | /api/tasks.xml | 
+2
source

Source: https://habr.com/ru/post/898403/


All Articles