techdays 2013 juhani lind: acceptance test driven development with vs 2012

27
Régis Laurent Director of Operations, Global Knowledge Competencies include: Gold Learning Silver System Management Acceptance Test Driven Development With VS 2012 Juhani Lind 5-Mar-2013 Tieturi Oy

Upload: tieturi-oy

Post on 01-Nov-2014

905 views

Category:

Documents


0 download

DESCRIPTION

 

TRANSCRIPT

Page 1: TechDays 2013 Juhani Lind: Acceptance Test Driven Development With VS 2012

Régis Laurent Director of Operations, Global Knowledge Competencies include: Gold Learning Silver System Management

Acceptance Test Driven Development With VS 2012 Juhani Lind 5-Mar-2013 Tieturi Oy

Page 2: TechDays 2013 Juhani Lind: Acceptance Test Driven Development With VS 2012

Oh Brother, Where Did We Go Wrong?

What the Customer described …

… And what was

finally delivered.

Page 3: TechDays 2013 Juhani Lind: Acceptance Test Driven Development With VS 2012

ATDD - A Bridge Over Troubled Gap Using Tests As Specification! • Collaborative specification • Using examples to illustrate • Driving the development • Validating frequently

Ultimate Benefits! • Executable specification • Living, up-to-date documentation • Learning by getting feedback

Page 4: TechDays 2013 Juhani Lind: Acceptance Test Driven Development With VS 2012

So many names …

#td2013fi

Page 5: TechDays 2013 Juhani Lind: Acceptance Test Driven Development With VS 2012

Quick Overview

Requirement +

Acceptance Criteria

Specification by

Examples

Implementing Examples as Tests

List of Requirements

Development (incl. implementation, testing and reviews) Next Requirement

This is a team effort!

Page 6: TechDays 2013 Juhani Lind: Acceptance Test Driven Development With VS 2012

Constraints Matter Too!

Requirement Feature

Acceptance Criteria/

Constraints

Acceptance Criteria

+ Examples

Functionality

Performance Usability

Security …

Page 7: TechDays 2013 Juhani Lind: Acceptance Test Driven Development With VS 2012

What actually gets driven by ATDD?

Collaboration Architecture Design

Implementation Testing

Testable!

Page 8: TechDays 2013 Juhani Lind: Acceptance Test Driven Development With VS 2012

Two Examples of ATDD Tools

SpecFlow Fit Framework for Integrated Test

Binds business readable behaviour spesification and examples to .NET.

Integrates the work of customers, analysts,

testers and developers.

http://www.specflow.org/specflownew/ http://fit.c2.com/

Page 9: TechDays 2013 Juhani Lind: Acceptance Test Driven Development With VS 2012

Specification by Example in SpecFlow

SpecFlow uses a business-readable domain specific language called Gherkin to express examples and their - preconditions (Given) - actions (When) - verification steps (Then)

Feature Scenario 1

Given When Then

Scenario 2

Given When Then

Page 10: TechDays 2013 Juhani Lind: Acceptance Test Driven Development With VS 2012

SpecFlow Overview SpecFlow Feature

(Gherkin) SpecFlow

Auto-Generated Code

User Written Feature Code in .NET

VS2012 Test Explorer

Unit Test Provider (e.g. NUnit)

System Under Test Code

Runs tests

Implemented by

Calls

Page 11: TechDays 2013 Juhani Lind: Acceptance Test Driven Development With VS 2012

SpecFlow in Action 1: Examples with Gherkin

Page 12: TechDays 2013 Juhani Lind: Acceptance Test Driven Development With VS 2012

SpecFlow in Action 2: Generating Steps

Page 13: TechDays 2013 Juhani Lind: Acceptance Test Driven Development With VS 2012

SpecFlow in Action 3: Implementation in C#

Page 14: TechDays 2013 Juhani Lind: Acceptance Test Driven Development With VS 2012

SpecFlow in Action 4: Running scenarios

Page 15: TechDays 2013 Juhani Lind: Acceptance Test Driven Development With VS 2012

The Hamlet Dilemma

To test through the UI or not to test – oh what a question.

Well … it depends …

Page 16: TechDays 2013 Juhani Lind: Acceptance Test Driven Development With VS 2012

Where To Look For Verification?

Presentation Data Business Logic

System Under Test

External System

Page 17: TechDays 2013 Juhani Lind: Acceptance Test Driven Development With VS 2012

ATDD

From ATDD to Test Driven Development (TDD)

TDD

TDD Cycle - Design with tests - Implement tests - Run one test to see it fail! - Implement the simplest

solution - Run the test to see it pass! - Refactor, repeat

This RED – GREEN – Refactor cycle applies to both.

Page 18: TechDays 2013 Juhani Lind: Acceptance Test Driven Development With VS 2012

Specification by Example with Fit

Fit uses the classic HTML tables to express examples. The structure of HTML tables specify - a Fit fixture - preconditions and actions - verification rules

<table> <tr>

<td> </td> <td> </td> <td> </td> <td> </td>

</tr> </table>

Page 19: TechDays 2013 Juhani Lind: Acceptance Test Driven Development With VS 2012

FIT Overview HTML Tables - Examples - Result

User Written Fit Fixture <dll >

System Under Test

Action Fixture Presentation Layer

Business Layer

Data Layer

Column Fixture

Row Fixture

Injection to public variables. Calls to public methods.

Page 20: TechDays 2013 Juhani Lind: Acceptance Test Driven Development With VS 2012

Fit in Action 1: Examples as HTML Table

Page 21: TechDays 2013 Juhani Lind: Acceptance Test Driven Development With VS 2012

Fit in Action 2: Fixture Code

Page 22: TechDays 2013 Juhani Lind: Acceptance Test Driven Development With VS 2012

Fit in Action 3: Execution Command

Page 23: TechDays 2013 Juhani Lind: Acceptance Test Driven Development With VS 2012

Fit in Action 4: Result as HTML Table

Page 24: TechDays 2013 Juhani Lind: Acceptance Test Driven Development With VS 2012

Watch Your Language!

Gherkin itself has been translated to 40 languages. The language is set in the config file with the <language> element. <language feature = ”fi-FI” />

The names of - public variables and - public methods in Fit fixtures should be as close to the Customer’s language as possible.

SpecFlow Fit

Specification and examples should use the Customer’s language and terminology.

Page 25: TechDays 2013 Juhani Lind: Acceptance Test Driven Development With VS 2012

Building the RIGHT solution …

… the RIGHT way!

ATDD!

But something

else is needed too!

Page 26: TechDays 2013 Juhani Lind: Acceptance Test Driven Development With VS 2012

t

Q&A

Page 27: TechDays 2013 Juhani Lind: Acceptance Test Driven Development With VS 2012

© 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentations. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

Thank you for coming! Feedback can be given via mobile or laptop through techdays.fi seminar schedule.

#td2013fi