TechDays 2013 Juhani Lind: Acceptance Test Driven Development With VS 2012
Acceptance TestDrivenDevelopment RégisWith VS 2012 Laurent Director of Operations, Global KnowledgeJuhani Lind 5-Mar-2013 Competencies include: Gold Learning Silver System ManagementTieturi Oy
Oh Brother, Where Did We Go Wrong? … And what was finally delivered. What the Customer described …
ATDD - A Bridge Over Troubled GapUsing Tests As Specification!• Collaborative specification• Using examples to illustrate• Driving the development• Validating frequentlyUltimate Benefits!• Executable specification• Living, up-to-date documentation• Learning by getting feedback
Quick Overview This is a team effort! Requirement Specification Implementing + by Examples Acceptance Examples as Tests Criteria List of DevelopmentRequirements Next Requirement (incl. implementation, testing and reviews)
What actually gets driven by ATDD? Architecture Collaboration Design Testable! Implementation Testing
Two Examples of ATDD Tools Fit SpecFlow Framework for Integrated Test Binds business readable Integrates the work of behaviour spesification customers, analysts, and examples to .NET. testers and developers. http://www.specflow.org/specflownew/ http://fit.c2.com/
Specification by Example in SpecFlow Feature Scenario 1 SpecFlow uses a business-readable Given domain specific language called Gherkin When to express examples and their Then - preconditions (Given) - actions (When) Scenario 2 - verification steps (Then) Given When Then
SpecFlow Overview SpecFlow SpecFlow FeatureAuto-Generated Code (Gherkin) VS2012 Test Explorer Runs tests Implemented by System Under Test Code Calls Unit Test Provider User Written (e.g. NUnit) Feature Code in .NET
The Hamlet Dilemma To test through the UI or not to test – oh what a question. Well … it depends …
Where To Look For Verification? System Under Test Presentation Business Logic Data External System
From ATDD to Test Driven Development (TDD) TDD Cycle - Design with tests - Implement tests - Run one test to see it fail! - Implement the simplest solution ATDD TDD - Run the test to see it pass! - Refactor, repeat This RED – GREEN – Refactor cycle applies to both.
Specification by Example with Fit <table> Fit uses the classic HTML tables to <tr> express examples. <td> </td> The structure of HTML tables specify <td> </td> - a Fit fixture <td> </td> - preconditions and actions <td> </td> - verification rules </tr> </table>
FIT OverviewHTML Tables Presentation Layer- Examples Action Fixture- ResultInjection to public variables. Calls to public methods. Business Layer Column FixtureUser WrittenFit Fixture <dll > Data Layer Row FixtureSystemUnderTest
Watch Your Language! Specification and examples should use the Customer’s language and terminology.SpecFlow FitGherkin itself has been translated to The names of40 languages. - public variables andThe language is set in the config file - public methodswith the <language> element. in Fit fixtures should be as close to the Customer’s language as<language feature = ”fi-FI” /> possible.
But something else is needed too!Building the RIGHT solution … … the RIGHT way! ATDD!