Is it possible to bind examples to external data sources like Excel/Database/XML/txt?

1,257 views
Skip to first unread message

nitro52

unread,
Mar 2, 2011, 10:05:32 PM3/2/11
to SpecFlow
Our business logic requires us to run the same test with many
iterations as the expected result will depend on the dataset. One
thing it seems that specflow is lacking a bit with how it manages its
tables. Is it possible so bind this to an external source so you can
manage your tables in applications like excel?

Gáspár Nagy

unread,
Mar 5, 2011, 3:50:50 PM3/5/11
to SpecFlow
If I understand your problem well, this would be a special feature of
Gherkin to allow examples from external source. This is outside of
SpecFlow's area, as we use the Gherkin language/parser from Cucumber.
I've read a discussion there about this already (i don't find it now,
sorry), but basically the answer was, that it is better to keep all
information at the same place, ie in the Ghekin file.

nitro52

unread,
Mar 6, 2011, 6:44:39 PM3/6/11
to SpecFlow
Isn't Gherkin just the format of the language not the tool. I don't
see why the tool that uses the language could not extend on that to
make it a more specialized tool. I can see that it would be useful to
keep the information in one place but currently there are no tools to
help you format/edit/delete/create tables. this can be very time
consuming for data driven tests. hence if you could simply map the
test to say an excel spread sheet then all this hassle is handled by
excel.

I haven't really looked at the source code but how flexible is the
parser? could we create a custom solution for ourselves?

Gáspár Nagy

unread,
Mar 7, 2011, 3:48:18 PM3/7/11
to SpecFlow
Technically it is possible. For some time, SpecFlow even had an own
parser.

I think the specification language is a key point for such a tool and
I think the language is better if it is more broadly accepted. Though
there are some constraints involved by the shared parser, there are a
lot of benefits too, like the continuously evolving natural language
support, etc.

I agree, that managing the tables is painful, but I think this can be
improved.

BTW: Thinking it over once more, you can even do external data source
right now: the scenario outlines are generated as methods with
parameters for the different arguments in the (partial) test class.
You can make another part for the partial class and feed the method
from external data source. Maybe this trick could be done with a
custom generator, that you can configure without even changing
SpecFlow itself (see https://github.com/techtalk/SpecFlow/wiki/Using-SpecFlow-with-CodedUI-API
as example).
Reply all
Reply to author
Forward
0 new messages