Is it possible to have a Scenario Outline with Parameterized Example

309 views
Skip to first unread message

Sourin K Sen

unread,
May 21, 2014, 12:26:52 PM5/21/14
to cu...@googlegroups.com
Hi,

Consider this requirement :
The application I am working on, takes an xml file as input, processes it, saves the data and sends out an xml file based response containing key information that needs to be verified.
My test scenario is like this :

Step 1: Given I have a file <filename>
Step 2: When I process the file
Step 3: Then I receive the response which matches <expected_response_filename>

Now my problem is I can have anywhere between 5 to 500 input files to test for a single scenario based upon the data permutation/combination (scenario outlines) present in the file.
Creating those many files isn't a problem as I wrote a small utility to generate those files with the outlines.

The real problem is to having to write down all the file names in the gherkin script.

Even if I use the Scenario Outline feature, still it seems that I have to write down the file names in the Example portion along with the expected file names.

Is there a way by which I can simply mention folder paths in the Example section(an input file folder and an expected file folder) and the scenario outline can then pick 1 file from there, process the scenario, match the result with the corresponding expected file (based on file name) in the expected folder and then repeat the process for all the other files?

Or maybe somehow parametrize the Example section so as to provide file names on the go?

Thanks,
Sourin

Oscar Rieken

unread,
May 21, 2014, 1:11:51 PM5/21/14
to cu...@googlegroups.com
On Wed, May 21, 2014 at 12:26 PM, Sourin K Sen <souri...@gmail.com> wrote:
Hi,

Consider this requirement :
The application I am working on, takes an xml file as input, processes it, saves the data and sends out an xml file based response containing key information that needs to be verified.
My test scenario is like this :

Step 1: Given I have a file <filename>
Step 2: When I process the file
Step 3: Then I receive the response which matches <expected_response_filename>

Now my problem is I can have anywhere between 5 to 500 input files to test for a single scenario based upon the data permutation/combination (scenario outlines) present in the file.
Creating those many files isn't a problem as I wrote a small utility to generate those files with the outlines.

The real problem is to having to write down all the file names in the gherkin script.
Why would you have to write all those file names? If you have a utility that creates them why not just create them in a temp directory for each scenario and then in your step just collect the file names from there. then in your scenario you can actually state the type of file processing that needs to take place?

I don't know what you are building but if all you need is types of files to be processed. and you are testing the processing behavior this seems like a good option.
 

Even if I use the Scenario Outline feature, still it seems that I have to write down the file names in the Example portion along with the expected file names.

Is there a way by which I can simply mention folder paths in the Example section(an input file folder and an expected file folder) and the scenario outline can then pick 1 file from there, process the scenario, match the result with the corresponding expected file (based on file name) in the expected folder and then repeat the process for all the other files?

Or maybe somehow parametrize the Example section so as to provide file names on the go?

Thanks,
Sourin

--
Posting rules: http://cukes.info/posting-rules.html
---
You received this message because you are subscribed to the Google Groups "Cukes" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cukes+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Paolo Ambrosio

unread,
May 21, 2014, 1:30:38 PM5/21/14
to cu...@googlegroups.com
If you want to describe your requirements that way, IMO Cucumber is
not the right tool for you. Cucumber is primarily a communication
tool, and you are not communicating anything. An approach that conveys
to the reader the purpose of each scenario would be something like...
(guessing a random domain)

# create the input file
Given a report with a repeated transaction
# you might want to process different types of file, so specify one
instead of using the generic "file"
When the report is processed
# read the output and check the outcome
Then the processed report should have a line with the count of those
transactions

or in a more detailed style...

Given a report with the following transactions:
| date | description |
| 1/2/2003 | payment1 |
| 2/3/2003 | payment1 |
| 3/4/2003 | payment1 |
When the report is processed
Then the processed report should have the following transactions:
| count | description |
| 3 | payment1 |

If all your logic is in the input and output files, you'd rather use
JUnit, RSpec, etc. or even a simple shell script!


Paolo
Reply all
Reply to author
Forward
0 new messages