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 - Background Illustration
SpecFlow - Background Illustration
Background 关键词适用于在“特征档案”内所有情景之前复制相同的步骤。 我们可能把这些步骤转移到背景之下,在背景部分下将它们放下。
它有助于在设想中增加背景。 它可以有不止一个步骤。 因此,它应在执行每一设想方案之前执行,但应设员额。 栏目
背景在第一个Example或Scenario之前保持,保持同样的登革水平。 简言之,它用于宣布所有测试的共同步骤。
在上述例子中,有两种设想,背景步骤应在执行每一设想方案之前运作一次。
Background Rules
让我们在适用背景时描述一些规则——
它应当用来确定简单的步骤,除非我们被迫将申请提交需要采取复杂步骤的国家。 根据项目利益攸关方的要求。
它应当是简短和现实的。
所有情景也应简短。
Background Example
让我们看一例,我们利用背景步骤在特征文件的所有测试之前加以执行。 例如,为了增加申请的正常和行政用户,我们要求在实施假想普通用户增加之前采取下列步骤:
申请号:URL。
提交用户名和密码
Step 1: Create a Feature File
本章——特征文件——详细讨论了如何建立特征档案的细节。
Feature: Member addition Background: Given launch URL Then enter name and password Scenario: Normal user addition Given user is on normal user addition screen When enters normal user details Then user should be added as normal user Scenario: Admin user addition Given user is on admin user addition screen When enters admin user details Then user should be added as admin user
Step 2: Create a Step Definition File
本章——步骤定义文件——详细讨论了如何建立步骤定义档案的细节。
using System; using TechTalk.SpecFlow; namespace SpecFlowProject1.Features{ [Binding] pubpc class MemberAdditionSteps{ [Given(@"launch URL")] pubpc void GivenLaunchURL(){ Console.WriteLine("Url launched"); } [Given(@"user is on normal user additon screeen")] pubpc void GivenUserIsOnNormalUserAdditonScreeen(){ Console.WriteLine("User is on normal user addition screen"); } [Given(@"user is on admin user addition screen")] pubpc void GivenUserIsOnAdminUserAdditionScreen(){ Console.WriteLine("User is on admin user addition screen"); } [When(@"enters normal user details")] pubpc void WhenEntersNormalUserDetails(){ Console.WriteLine("User enters normal user details"); } [When(@"enters admin user details")] pubpc void WhenEntersAdminUserDetails(){ Console.WriteLine("User enters admin user details"); } [Then(@"enter name and password")] pubpc void ThenEnterNameAndPassword(){ Console.WriteLine("User enters name and password"); } [Then(@"user should be added as normal user")] pubpc void ThenUserShouldBeAddedAsNormalUser(){ Console.WriteLine("User should be added as normal user"); } [Then(@"user should be added as admin user")] pubpc void ThenUserShouldBeAddedAsAdminUser(){ Console.WriteLine("User should be added as admin user"); } } }
Step 3: Execution & Results
选择SpecFlow Project(2),然后点击Run All Tests in View。
选择 热用户添加情景,然后点击。 这一结果的公开额外产出联系。
在上述产出中,背景步骤—— Given Url射出和 。
在上述产出中,背景步骤—— Given Url射出和 。
Advertisements