490 likes | 1.68k Views
BDD with SpecFlow. Why BDD?. 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?.
E N D
Why BDD? • 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? • 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? • Details are lost when translating from business requirements to traditional MSTest unit tests. • With many handoffs it’s very easy to have a full set of tests and still build the wrong software. • 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: http://stackoverflow.com/questions/307895/what-is-the-most-mature-bdd-framework-for-net
SpecFlow Overview • SpecFlow adds a thin layer on top of traditional automated tests. • Specification - readable text • Binding - maps from readable text->code • MSTest (Behind the scenes) • Traditional Automated Tests • MSTest -> System • SpecFlow Tests • Specification -> Binding -> MSTest -> System
SpecFlow - One Time Setup • Install Visual Studio Plugin • nuget: Install-Package SpecFlow • Add to app.config: <specFlow> <unitTestProvider name=”MsTest”/> </specFlow>
Next Steps • Install Visual Studio Plugin: • http://visualstudiogallery.msdn.microsoft.com/9915524d-7fb0-43c3-bb3c-a8a14fbd40ee • Does SpecFlow replace all our functional tests? No... not yet. • SpecFlow - Workflow & key examples • Traditional Functional Tests - everything else