c# - SpecFlow test with Gherkin table also trying column name in tests -


i have specflow feature:

given have cooldata <a> , <b> , <c> , <d>:  |                | b        | c         | d            | | cool data        |          | 1.3       | cool notes   | | cool data        | 1.4      |           | cool notes   | | cool data        | 1.3      | 1.3       | cool notes   | | cool data        | 1.3      | 1.3       | cool notes   |   

for have method:

[given(@"given have cooldata (.*) , (.*) , (.*) , (.*) :")]     public void givenihavecooldatawithand(string p0, string p1, string p2, string p3, table table)     {         var cool = new cooldata         {             a= p0,             b= decimal.parse(p1),             c= decimal.parse(p2),             d= p3,         };     } 

my problem: when run test, p0, p1, p2 , p3 mapped strings literally "<a>", "<b>", "<c>" , "<d>", instead of values in tables. doing wrong? i'm trying repeat unit test each row in table.

you have misunderstood how gherkin works. have done conflate 2 concepts, table , scenario examples. see the documentation cucumber , @ difference between data tables , scenario outlines

i believe don't want table in instance , should use scenario outline examples, this:

scenario outline: title     given have cooldata <a> , <b> , <c> , <d>  examples: |                | b        | c         | d            | | cool data        |          | 1.3       | cool notes   | | cool data        | 1.4      |           | cool notes   | | cool data        | 1.3      | 1.3       | cool notes   | | cool data        | 1.3      | 1.3       | cool notes   |   

this cause 4 tests generated each 1 running 1 line of data example

you need adjust step method not expect table (as table set of examples)

[given(@"given have cooldata (.*) , (.*) , (.*) , (.*)")]     public void givenihavecooldatawithand(string p0, string p1, string p2, string p3)     {         var cool = new cooldata         {             a= p0,             b= decimal.parse(p1),             c= decimal.parse(p2),             d= p3,         };     } 

Comments

Popular posts from this blog

wireshark - USB mapping with python -

c++ - nodejs socket.io closes connection before upgrading to websocket -

Deploying Qt Application on Android is really slow? -