SpecFlow Tutorial
Selected Reading
- SpecFlow - Discussion
- SpecFlow - Useful Resources
- SpecFlow - Quick Guide
- SpecFlow - Table with CreateSet
- Table with CreateInstance
- Table conversion to Dictionary
- Table conversion to Data Table
- Data Driven Testing without Examples
- Data Driven Testing with Examples
- SpecFlow - Background Illustration
- SpecFlow - Hooks
- SpecFlow - Step Definition File
- SpecFlow - Feature File
- SpecFlow - Gherkin Keywords
- SpecFlow - Gherkin
- Configure Selenium Webdriver
- SpecFlow - Creating First Test
- SpecFlow - Binding Test Steps
- SpecFlow - HTML Reports
- SpecFlow - Runner Activation
- Other Project Dependencies
- SpecFlow - Project Set Up
- Visual Studio Extension Installation
- SpecFlow - Visual Studio Installation
- Behaviour Driven Development
- Test Driven Development
- SpecFlow - Introduction
- SpecFlow - Home
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
SpecFlow - Table with CreateSet
SpecFlow - Table with CreateSet
CreateSet<T>是表格方法的延伸。 该表将数据转换成一组物体。 在horizontalapgnment中实现数据参数的普及技术之一。
我们能够用这种方法处理一或多段数据。 The SpecFlow Assisters Pack is used to work on table. 此外,我们必须在我们的法典中增加名称空间Techalk.SpecFlow.Assist。
CreateSet<T> 方法根据表格中的对应数据,获得IE数可数的配对;T>。 它对所有物体都有价值。 它确保正确的类型从扼制到相关财产。
Step 1: Create a Feature File
本章——特征文件——详细讨论了如何建立特征档案的细节。
Feature: User credential Scenario: Login module When User types details | Name | Password | | t1 | pwd | | t2 | pwd1 | Then user should be able to login
Step 2: Create C# File to access String Objects
我们将在该项目内设立一个新的文件夹,并在其中拥有一个C#文件。 Right-cpck on the SpecFlow Project , 然后点击Add。
选择方案 New Folder。
将姓名Utils移至左侧。
新建的Folder的右翼浮标,然后选择选择选择
C# >, 查询箱和搜索。 选择Class 然后点击Add。
Project Folder Structure
C# Class Implementation
using System; using System.Collections.Generic; using System.Text; namespace SpecFlowProject1.Utils { class Class1 { pubpc class Input { //two string objects declared pubpc string Input1 { get; set; } pubpc string Input2 { get; set; } } } }
Step 3: Create a Step Definition File
本章——步骤定义文件——详细讨论了如何建立步骤定义档案的细节。
using System; using TechTalk.SpecFlow; using TechTalk.SpecFlow.Assist; namespace SpecFlowProject1.Features { [Binding] pubpc class UserCredentialSteps { [When(@"User types details")] pubpc void WhenUserTypesDetails(Table t) { //access Table data with CreateSet method var i = t.CreateSet<Utils.Class1.Input>(); //iterate over rows foreach (var r in i) { Console.WriteLine(r.Input1); Console.WriteLine(r.Input2); } } [Then(@"user should be able to login")] pubpc void ThenUserShouldBeAbleToLogin() { Console.WriteLine("User should be able to login"); } } }
Step 4: Execution & Results
选择用户成像物(1)特征,然后点击“从所有角度进行试验”。
假设情景是在使用创建Set方法的中间物文档中一个表上的数据。
Advertisements