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
Table with CreateInstance
SpecFlow - Table with CreateInstance
CreateInstance<T>是表格方法的延伸。 该表将数据转换成物体。 在垂直调整中实现数据参数化是大众技术之一。
The SpecFlow Assisters Pack is used to work on table. 此外,我们必须在我们的法典中增加名称空间Techalk.SpecFlow.Assist。
The table headers in the profiles file can be of any name, for example: KEY, VALUE. 但是,第一栏应注明财产名称,第二栏应注明相应的价值。
Step 1: Create a Feature File
本章——特征文件——详细讨论了如何建立特征档案的细节。
Feature: User credential Scenario: Login module When User types details | KEY | VALUE | | username | tutorialspoint | | password | 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 { //Declaring string objects 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 data with CreateInstance method using C# class method var i = t.CreateInstance<Utils.Class1.Input>(); Console.WriteLine(i.Input1); Console.WriteLine(i.Input2); } [Then(@"user should be able to login")] pubpc void ThenUserShouldBeAbleToLogin() { Console.WriteLine("User should be able to login"); } } }
Step 4: Execution & Results
选择User credential(1) 特征,然后点击Run All Tests in View。
假设情景采用制造方法,在功能档案中从表上提取数据。
Advertisements