Thursday, September 26, 2019

SpecFlow - Table

using TechTalk.SpecFlow.Assist
1. CreateInstance<T>
| LanguageName | LanguageLevel|

| Indian  | Basic            |

var lan = table.CreateInstance<Languages>();

2. CreateSet<T> - horizontal data

| LanguageName | LanguageLevel|
| Indian  | Basic            |
| French   | Conversational   |
| Spanish  | Fluent           |
| Mandarin | Native/Bilingual |

Create a class, table header must match with the members
public class Languages
{
 public string LanguageName{get;set;}
 public string LanguageLevel{get;set}
}

In Step Definition
var languages = table.CreateSet<Languages>();
foreach(var lan in languages)
{
lan.LanguageName
lan.LanguageLevel

}
3.Dynamic
using Specflow.Assist.Dynamic, Install nuget package first

dynamic credentials = table.CreateDynamicInstance();
IEnumerable <dynamic> credentials = table.CreateDynamicSet();

No comments:

Post a Comment

API interview questions

  https://www.katalon.com/resources-center/blog/web-api-testing-interview-questions/ Top 50+ Web API Testing Interview Questions [Ultimate l...