Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 19-Jan-14 © Copyright: City Boy Salary : Simon Powers : 2014 Brown Bag – Behaviour Driven Development with Specflow Brown Bag – Behaviour Driven Development.

Similar presentations


Presentation on theme: "1 19-Jan-14 © Copyright: City Boy Salary : Simon Powers : 2014 Brown Bag – Behaviour Driven Development with Specflow Brown Bag – Behaviour Driven Development."— Presentation transcript:

1 1 19-Jan-14 © Copyright: City Boy Salary : Simon Powers : 2014 Brown Bag – Behaviour Driven Development with Specflow Brown Bag – Behaviour Driven Development with

2 2 19-Jan-14 © Copyright: City Boy Salary : Simon Powers : 2014 What is BDD? BDD changes the way we define and document software and helps us to think more about how our software behaves than how it is structured. Behaviour Driven Development is an Agile process that comes from TDD that allows teams to define tests upfront in common business language.

3 3 19-Jan-14 © Copyright: City Boy Salary : Simon Powers : 2014 Benefits of using the BDD process Communication Increases communication and understanding within and outside of the team Clarity Drives out ambiguities in stories early before valuable coding time is used up Documentation Gives specification by example – living documentation which can be shared to downstream systems Business led Functionality is driven by the business and has to conform to acceptance criteria Testable Ensures functionality is testable providing robust code. Get integration and regression testing for free. Progress indicator Instant feedback of development progress as tests pass Instant feedback Tests and results are transparent at code check in and bugs identified immediately. Reduces support Reduces support by reducing bugs and misunderstanding of requirements. Documentation can be used to reduce support. Increased confidence Living documentation can highlight large test coverage with passing tests to downstream teams and gives developers confidence to make large changes knowing the interfaces have not been broken.

4 4 19-Jan-14 © Copyright: City Boy Salary : Simon Powers : 2014 Installing SpecFlow We will cover SpecFlow which is a free add-on for Visual Studio. http://www.specflow.org/ http://www.specflow.org/ SpecFlow can use any test runner – (Tested with MSTest and NUnit) Install SpecFlow 1.Add SpecFlow in Visual Studio through the Extension Manager 2. Add SpecFlow NuGet package to your test project 3. Add a feature file to your project

5 5 19-Jan-14 © Copyright: City Boy Salary : Simon Powers : 2014 Feature Tests As new features are added, we write tests around each feature. Tests are grouped by feature.

6 6 19-Jan-14 © Copyright: City Boy Salary : Simon Powers : 2014 Structure of a feature Feature tests are written in the format: Given -> When -> Then Given is the set up of the existing state before the test When is the action I am testing Then is the result I expect to get back Example of a test for a feature

7 7 19-Jan-14 © Copyright: City Boy Salary : Simon Powers : 2014 Structure of a feature The C# framework code is auto-generated Right click and creating step definitions to allow SpecFlow to generate the C# methods for developers to write wiring code into. Auto-generate C# method stubs

8 8 19-Jan-14 © Copyright: City Boy Salary : Simon Powers : 2014 Structure of a feature The C# framework code is auto-generated The auto-generated method stubs are complete but basic. Additional steps are required for best practices and code re-use. Auto-generate C# method stubs Stock ticker can be a variable to allow test re-use Variable names should be more descriptive

9 9 19-Jan-14 © Copyright: City Boy Salary : Simon Powers : 2014 Structure of a feature The C# framework code is auto-generated The auto-generated method stubs are complete but basic. Additional steps are required for best practices and code re-use. Change hard coded string to wild card Rename variable and add stock ticker variable

10 10 19-Jan-14 © Copyright: City Boy Salary : Simon Powers : 2014 Structure of a feature Feature file is colour coded Variables are a different colour Test font colour is now black as there are matching code stubs

11 11 19-Jan-14 © Copyright: City Boy Salary : Simon Powers : 2014 Structure of a feature Feature file is colour coded Variables are a different colour Test font colour is now black as there are matching code stubs Further enhancements with tabled data The test is run once for each line in the table

12 12 19-Jan-14 © Copyright: City Boy Salary : Simon Powers : 2014 Turning a feature into a test Given [The test puts records in the database] When [The test uses a service client to call the service under test] Then [The test compares the result with an expected result]

13 13 19-Jan-14 © Copyright: City Boy Salary : Simon Powers : 2014 Turning a feature into a test Given [The test puts files in a directory] When [The test executes the dtsx (ssis) package] Then [The test compares the data in the database with an expected result]

14 14 19-Jan-14 © Copyright: City Boy Salary : Simon Powers : 2014 Living Documentation Documentation can be generated from the tests on check-in via the build server using Pickles. (http://www.picklesdoc.com)http://www.picklesdoc.com Documentation can be generated in HTML (with or without search capabilities), JSON, Word, DITA or Excel formats. Documentation can be generated via MS Build with a supplied task or with PowerShell Generating documentation Example Feature text appears here, so this can be more descriptive Test result of last test run is appended to the documentation.

15 15 19-Jan-14 © Copyright: City Boy Salary : Simon Powers : 2014 Resources Other BDD tools Cucumber - http://cukes.info/http://cukes.info/ Rspec - http://rspec.info/http://rspec.info/ Other documentation generation systems Relish (https://relishapp.com) SpecLog (http://www.speclog.org)http://www.speclog.org Other Resources Tutorial on SpecFlowSpecFlow


Download ppt "1 19-Jan-14 © Copyright: City Boy Salary : Simon Powers : 2014 Brown Bag – Behaviour Driven Development with Specflow Brown Bag – Behaviour Driven Development."

Similar presentations


Ads by Google