BDD with SpecFlow
Why BDD? 1. BDD helps build the right thing. Traditionally there are many handoffs - Requirements, development, component testing, integration testing and finally customer usage. BDD shares a specification through all stages of development.
Why BDD? 2. BDD documents what is actually built Documentation reflects how the system actually behaves. Documentation is up-to-date and accurate. Good for long-term maintenance. Good for training new staff. Good for communicating with other teams.
How BDD? Up front, Product Managers, developers and QA define the behavior of the system collaboratively. They write a specification. The specification defines what Product Owners want, what developers build and what QA tests. The specification is used as a target for implementation and a means to validate the product.
Why not TDD? 1. Details are lost when translating from business requirements to traditional MSTest unit tests. 2. With many handoffs it’s very easy to have a full set of tests and still build the wrong software. 3. MSTest functional tests are inaccessible to product stakeholders.
BDD Frameworks: xBehave or xSpec? SpecFlow is xBehave-based xBehave Benefit: stakeholders can read and understand the tests Comparison: /what-is-the-most-mature-bdd- framework-for-net
SpecFlow Overview SpecFlow adds a thin layer on top of traditional automated tests. 1. Specification - readable text 2. Binding - maps from readable text- >code 3. MSTest (Behind the scenes) Traditional Automated Tests MSTest -> System SpecFlow Tests Specification -> Binding -> MSTest -> System
SpecFlow - One Time Setup 1. Install Visual Studio Plugin 2. nuget: Install-Package SpecFlow 3. Add to app.config:
Next Steps Install Visual Studio Plugin : m/ d-7fb0-43c3-bb3c- a8a14fbd40ee m/ d-7fb0-43c3-bb3c- a8a14fbd40ee Does SpecFlow replace all our functional tests? No... not yet. SpecFlow - Workflow & key examples Traditional Functional Tests - everything else