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 - Creating First Test
SpecFlow - Creating First Test
我们现在将在课堂图书馆建立一个档案,以分两个号码。
using System; namespace ClassLibrary2 { pubpc class Class1 { pubpc int Number1 { get; set; } pubpc int Number2 { get; set; } pubpc int Subtraction(){ return Number1 - Number2; } } }
Feature File Implementation
Step Definition File Implementation
上述特征档案的相应步骤定义,以及使用1级进行减员。
using ClassLibrary2; using FluentAssertions; using TechTalk.SpecFlow; namespace SpecFlowCalculator.Specs.Steps { [Binding] pubpc sealed class CalculatorStepDefinitions { private readonly ScenarioContext _scenarioContext; //instantiating Class1 private readonly Class1 _calculator = new Class1(); private int _result; pubpc CalculatorStepDefinitions(ScenarioContext scenarioContext) { _scenarioContext = scenarioContext; } [Given("the first number is (.*)")] pubpc void GivenTheFirstNumberIs(int number){ _calculator.Number1 = number; } [Given("the second number is (.*)")] pubpc void GivenTheSecondNumberIs(int number){ _calculator.Number2 = number; } [When("the two numbers are subtracted")] pubpc void WhenTheTwoNumbersAreSubtracted(){ _result = _calculator.Subtraction(); } [Then("the result should be (.*)")] pubpc void ThenTheResultShouldBe(int result){ _result.Should().Be(result); } } }
Executing the Test
建立上述解决办法,然后在我们从 试验获取后继信息之后进行试验。
选定SpecFlow Project1,在Run All test in View上点击。
结果显示为1 通过<>。 连同执行期限。 选择 减去这一结果的额外产出,以获得结果细节。
每个试验步骤的执行结果都显示。
专题卷宗中的所有步骤都按现状执行。 此外,《步骤定义文件》中的相应方法也随着执行时间的推移而表现出来。
Advertisements