Using data table could be very helpful when you write spec
in Gherkin. Consider the following example.
You have a registration form with first name, last name,
email address and password fields. The spec can look like the followings:
a.
Without Data table
b.
With Data table
There are two benefits of using data table here.
1. It gives better readability and maintainability.
2. If you do not use data table, you will have to
write individual step definitions for every inputs. Whereas, if you use data
table you can get the work done using a single step definition as shown below
Another representation of data table is
horizontal layout. Suppose you have a user login page. And you want to test
successful login function. So the spec will look like following
Unlike previous example, here data table
represents a horizontal layout. Left column represents the items and right
column represents corresponding data. Step definition of the above will look
something like the following:
Practice this and hopefully you will find
this handy. Thanks.
The less we can code, the more cucumber is helping us. I see it that way.
ReplyDeleteIn that way I am ok with the if else block auto generated by specflow. Just sharing.
Thanks for the comment. I'm not well conversant with specflow. I'll try to explore how it generates if else block. Thanks again.
DeleteCool and that i have a nifty present: What To Expect When Renovating A House small home additions
ReplyDelete