Specflow - large examples table


(steven) #1

Hello,

Any specflow experts in?

I have a scenario outline, and in the examples table there are around 14 different fields.

I have two tables that have similar data. At the moment I have two methods that can parse this data but there is a lot of duplication of code.

Is there a way of using specflow scenario outline/example and sending back a list of all the objects, so I don’t have to have item1 and item2…and item14?

Thanks


(Joe) #2

Hello Steven!

I’d like to clarify what you mean before offering help or a solution. Do you have something like this?

Given ,,…
When my process executes
Then the response is “X”

item1 item2 item3 item4 … item 14
1 “test” 4.2 true “dog”
34 “cat” 7.3 false “car”

Joe


(steven) #3

Scenario outline:
given…
when i supply the following data and …
then…

examples:
| variable1 | variable2 |…|Variable 14|
| data1 | data 2 |…data14|

I am using the examples table to pump data into an application multiple times.

so the step file method looks like
with tis (.) and (.) etc


(Joe) #4

Hello Steven!

I just saw that my example did not clearly show the data used from the table. I meant to show

Given variable1, variable2,…variable14

When I look at the scenario you provided, I wasn’t sure if the data was provided in the Given statement or the When statement.

Also, are all 14 variables required for the test? Might there be an opportunity to use less and isolate parts of the behavior under test?

Joe


(steven) #5

hmm. I know what you mean, it is a large data set, but it’s the data required to complete a user journey.


(Joe) #6

Hello Steven!

I understand many user journeys need a lot of data for their completion. When we quote insurance, there is driver data, vehicle data, and other data required for the quote. However, we can break up the quote into many smaller transactions and evaluate them in isolation. I was wondering if that is possible.
That is, the user needs 14 pieces of data for the journey. Do they need all 14 for all parts of the journey? Is it possible that three are needed to start, three more in the middle, and so forth?

Joe


(steven) #7

All of this data is on one page. I’m guessing there is no way to group these up? :slight_smile:

I’ve gone for an additional method within the code that populates my object with the shared fields.


(Joe) #8

Hello Steven!

Thanks for the info!

What I have done with SpecFlow is to use the Given statement code skeleton to set up the test. In this case, you would call your code that populates your object with the shared fields. If there is other set up required, I’ve executed that set up as well.
The When statement executes the action. If I assume your page is a web page, then this action is a navigation or a submit.

After the action is executed, what happens next? Navigation to another page? Collect data from another page?

Joe


(steven) #9

the data set is all contained on the page. so I’m dropping multiple scenarios when I get to a specific point.

Is it possible to keep the data in a CSV file or something, and read it all into a single variable?


(Joe) #10

Hello Steven!

I’ve been re-reading our conversation. I’m not sure I’m helping and it is challenging to explore testing challenges in this context.

Your testing challenge is an interesting one but I’m not sure I’m fully appreciating its scope. When we started, you were looking for suggestions to easily group data and you were using SpecFlow. Also, you mention having to present the data multiple times to the application. Your last comments give me the impression that you want to have some method to store the data and move it easily into an object.

I have a suggestion for the data-to-object challenge but wanted to ask first if it is possible to provide screen shots of the application, and, perhaps, some idea of the testing objective.

You mentioned a CSV file for storing your data. A CSV could be used but the parsing could be a distraction. One method I have used to stored a large amount of data is to use a JSON format. In C#, you can define a class that represents your data. Using NewtonSoft, you can serialize and deserialize the class quickly. Thoughts?

Joe


(steven) #11

I can’t really show screen shots of the application - we haven’t signed a contract yet, so it’s all a bit hush hush.

Basically it’s a loan application. One page has a bunch of fields - loan amounts. term. type etc.

I have a feature file which has around 9 scenarios in the examples table. So the test loops 9 times. and on the one page, it inserts up to 14 fields, depending on the criteria supplied (some fields are hidden depending on the selection)

I’ll look into storing the data as a json.