SlideShare uma empresa Scribd logo
1 de 57
First, Some History
Plan-Do-Check-Act
0 Originally called Plan-Do-Study-Act
0 Created by Walter Shewhart at Bell Labs during the
 1930s
Iterative & Incremental
           Development
0 The X-15 program in the 1950s used IID
Test-First in the Swinging 60s
0 X-15 team members seeded Project Mercury
   0 Time-boxed half-day iterations
   0 Tests were written first
   0 Reviews after each iteration
   0 Top-down development with stubs
We were doing incremental development as early as 1957, in Los Angeles, under
the direction of Bernie Dimsdale [at IBM’s Service Bureau Corporation]. He was
a colleague of John von Neumann, so perhaps he learned it there, or assumed it
    as totally natural. I do remember Herb Jacobs (primarily, though we all
 participated) developing a large simulation for Motorola, where the technique
             used was, as far as I can tell, indistinguishable from XP.

 When much of the same team was reassembled in Washington, DC in 1958 to
develop Project Mercury, we had our own machine and the new Share Operating
   System, whose symbolic modification and assembly allowed us to build the
            system incrementally, which we did, with great success.

 Project Mercury was the seed bed out of which grew the IBM Federal Systems
Division. Thus, that division started with a history and tradition of incremental
                                   development.

 All of us, as far as I can remember, thought waterfalling of a huge project was
 rather stupid, or at least ignorant of the realities… I think what the waterfall
   description did for us was make us realize that we were doing something
           else, something unnamed except for “software development.”

                                                             Gerald M. Weinberg
Waterfall in the 1970s & 80s
0 Blame the DoD and the CMMI
Other stuff was happening
0 Object-orientation
   0 Simula from the late 60s
   0 Smalltalk in the 70s at Xerox PARC
0 Software distribution
Into the 1990s
0 UML evolves
0 www arrives
What RUP was meant to be
What RUP actually was
RAD elaboration in the 90s
XP arrives
Test-Driven is in XP
Tests are Feedback in XP
Agile arrives
Agile is just XP, rebadged
and a Manifesto
The Philosophy of TDD
The Testing Game
0 Red:
   0 “Write a failing test”
0 Green:
   0 “Pass the failing test”
0 Refactor
   0 “Clean the implementation”
Write a failing test
0 To know what test to write, you must:
   0 Analyze your problem
   0 Design your solution
   0 Code intentionally
0 To dislike “Big Upfront Design” is not to dislike design
Agile Problem Analysis
0 System Metaphor
   0 Arises from the Architectural Spike
   0 A simple design with the defining quality of explaining the
     system design without reference to documents
0 User Experience
   0 Arises from the set of all user stories
   0 Provides a canvas onto which individual stories can be
     painted
0 User Story
   0 Describes a specific user expectation
   0 Provides the functional constraints of implementation
User Stories
0 A user story comprises one or more sentences in the
 everyday or business language of the end user that
 captures what the user wants to achieve
Agile Solutions
0 “Walk the solution”: for each user story
   0 Understand how this fits into the user experience
   0 Understand where the necessary functional
     implementation goes in the architecture
   0 Design the functional implementation
Goldilocks Design
0 Design only what you need
  0 avoid YAGNI (You Ain’t Gonna Need It)
0 Reuse existing implementation
   0 be DRY (Don’t Repeat Yourself)
0 Prefer sketched designs over definitive design
   0 allow TDD to be part of your design process
0 Don’t experiment in code
   0 use spikes where necessary
First Exercise
0 Brainstorm a realistic candidate application
0 Write a small set of user stories
0 Elaborate a user experience
0 Articulate a system metaphor
0 Time limit: one hour
Analysis & Design
0 There are a variety of approaches to functional
  analysis and implementation design
0 The most commonly used are:
  0 The UML
  0 CRC Cards
  0 Design Patterns
  0 Linguistics & Semantics
  0 Personas
  0 Storyboards
UML
0 The UML (Unified Modeling Language)
   0 It has the advantage that many developers have at least
     some familiarity
   0 It has the disadvantage of significant complexity
   0 Most agile practitioners use ‘sketch’ UML, typically on a
     whiteboard, in order to convey a mental model of a
     proposed solution
   0 Be indicative, not definitive
UML Use Case Diagram
0 Describes the functionality provided by a system in
 terms of actors and their goals represented as use
 cases
UML Activity Diagram
0 Used to describe the
 business and operational
 step-by-step workflows
 of components in a
 system
UML Sequence Diagram
0 Shows how processes operate with one another and
 in what sequence
UML Class Diagram
0 Describes the structure of a system by showing the
 system's classes, their attributes, methods, and the
 relationships among the classes
CRC Cards
0 Class Responsibility Collaboration cards are a
  brainstorming tool, proposed by Ward Cunningham and
  Kent Beck
0 They are typically used when determining which classes
  are needed and how they will interact
0 CRC cards are usually created from index cards on which
  are written:
  0   The class name
  0   Any base or derived classes (if applicable)
  0   The responsibilities of the class
  0   The names of other classes with which the class will
      collaborate to fulfil its responsibilities
CRC Card
Design Patterns
0 A general reusable solution to a commonly occurring
  problem within a given context
0 A design pattern is not a finished design that can be
  transformed directly into code; it is a description or
  template for how to solve a problem that can be used
  in many different situations
0 Typically show relationships and interactions
  between classes or objects, without specifying the
  final application classes or objects that are involved
Some Creational Patterns
0 Factory method
   0 Define an interface for creating an object, but let derived classes decide
     which class to instantiate
0 Lazy initialization
   0 Tactic of delaying the creation of an object, the calculation of a value, or
     some other expensive process until the first time it is needed
0 Object pool
   0 Avoid expensive acquisition and release of resources by recycling objects
     that are no longer in use
0 Resource acquisition is initialization
   0 Ensure that resources are properly released by tying them to the lifespan
     of suitable objects
0 Singleton
   0 Ensure a class has only one instance, and provide a global point of access
     to it
Some Structural Patterns
0 Adapter
   0 Convert the interface of a class into another interface clients
     expect
0 Bridge
   0 Decouple an abstraction from its implementation allowing the
     two to vary independently
0 Facade
   0 Provide a unified interface to a set of interfaces in a subsystem
0 Proxy
   0 Provide a surrogate or placeholder for another object to
     control access to it
Some Behavioural Patterns
0 Chain of responsibility
   0 Avoid coupling the sender of a request to its receiver by giving
     more than one object a chance to handle the request
0 Command
   0 Encapsulate a request as an object, thereby letting you
     parameterize clients with different requests, queue or log
     requests, and support undoable operations
0 Iterator
   0 Provide a way to access the elements of an aggregate object
     sequentially without exposing its underlying representation
0 Null object
   0 Avoid null references by providing a default object
Linguistics & Semantics
0 Using the meanings and
  relationships of words and
  phrases employed in the user
  stories and other material to
  construct a language map of
  the problem domain
0 Especially useful when
  dealing with ‘expert’ systems
Personas
0 Fictional characters
 created to represent
 the different user
 types within a
 targeted
 demographic, attitude
 and/or behaviour set
 that might use a
 site, brand or product
 in a similar way
Storyboards
              0 A technique
                borrowed
                from the
                film
                industry
              0 Shows the
                user
                experience
                in sequence
Second Exercise
0 Take one or more of the user stories from the first
  exercise and apply a selection of the analysis and
  design techniques
0 Draw up a list of the strengths and weaknesses of the
  techniques in relation to these particular user stories
0 Time limit: one hour
Testing Frameworks
0 MSTest
   0 Built-in to Visual Studio
0 Pex
   0 Experimental white-box testing from MS Research
0 NUnit
   0 Early open source port of JUnit for .net
0 MbUnit
   0 Another open source framework
0 xUnit
   0 Open source reset of NUnit
0 SpecFlow
   0 Open source behaviour-driven-development framework
Arrange, Act, Assert
0 The default pattern for unit tests
   1. Arrange all necessary preconditions and inputs
   2. Act on the object or method under test
   3. Assert that the expected results have occurred
Test naming conventions
0 Ad-hoc
   0 Anything goes
0 Behavioural
   0 Tests are named according to the behaviour under test
   0 Good fit for collaboration tests (distinct from unit tests)
     public void customer_pays_in_cheque_to_current_account()

0 Contractual
   0 Names follow the unit contract under test
     http://alandean.blogspot.com/2011/11/unit-test-naming-convention.html
xUnit Assertions
0 Fundamentals
   0   Assert.True(…) or Assert.False(…)
   0   Assert.Null(…) or Assert.NotNull(…)
   0   Assert.Equal(…) or Assert.NotEqual(…)
   0   Assert.Same(…) or Assert.NotSame(…)
0 Exceptions
   0 Assert.Throws<T>(…) or Assert.DoesNotThrow(…)
0 Type checks
   0 Assert.IsType(…) or Assert.IsNotType<T>(…)
   0 Assert.IsAssignableFrom<T>(…)
0 IEnumerable
   0   Assert.Empty(…) or Assert.NotEmpty(…)
   0   Assert.Single(…)
   0   Assert.Contains(…) or Assert.DoesNotContain(…)
   0   Assert.InRange(…) or Assert.NotInRange(…)
System.Diagnostics.Debug
0 Assertions
   0 Debug.Assert(…)
   0 Debug.Fail(…)
0 Publication
   0 Debug.Print(…)
   0 Debug.Write(…) or Debug.WriteIf(…)
   0 Debug.WriteLine(…) or Debug.WriteLineIf(…)
TDD at the Keyboard
1. Add a new test
2. Run all tests and see if the new one fails
3. Write some code
4. Run all tests and see them succeed
5. Refactor code
6. Repeat
Exercise 3
0 Create a solution with two class libraries:
   0 TicTacToe
   0 TicTacToe.Facts
0 Add a reference to xUnit.net in the Facts library
  0 http://nuget.org/

0 Use TDD to implement Tic-Tac-Toe
  0 http://gojko.net/2009/08/02/tdd-as-if-you-meant-it-revisited/
0 Time limit: one hour
Refactoring Code
0 A disciplined technique for restructuring an existing body of code,
  altering its internal structure without changing its external behaviour
0 Usually motivated by noticing a code smell
0 There are two general categories of benefits to the activity of refactoring
   0 Maintainability
      0 It is easier to fix bugs because the source code is easy to read and the
        intent of its author is easy to grasp
      0 This might be achieved by reducing large monolithic routines into a set of
        individually concise, well-named, single-purpose methods
      0 It might be achieved by moving a method to a more appropriate class, or
        by removing misleading comments.
   0 Extensibility
      0 It is easier to extend the capabilities of the application if it uses
        recognizable design patterns, and it provides some flexibility where none
        before may have existed
Refactoring Techniques
0 Techniques that allow for more abstraction
   0 Encapsulate Field: force code to access the field with getter and setter methods
   0 Generalize Type: create more general types to allow for more code sharing
   0 Replace Conditional with Polymorphism: move each leg of the conditional to an
       overriding method in a derived class and make the original method abstract
0 Techniques for breaking code apart into more logical pieces
   0 Extract Method: turn part of a larger method into a new method
   0 Extract Class: moves part of the code from an existing class into a new class
0 Techniques for improving names and location of code
   0   Move Method or Field: move to a more appropriate class
   0   Rename Method or Field: changing the name to one that better reveals its purpose
   0   Pull Up: move to a base class
   0   Push Down: move to a derived class
0 Longer list
   0 http://martinfowler.com/refactoring/catalog/index.html
Exercise 4
0 Create a solution with two class libraries:
   0 RomanNumerals
   0 RomanNumerals.Facts
0 Use TDD to solve the problem
  0 https://sites.google.com/site/tddproblems/all-problems-1/Roman-number-conversion

0 Refactor the code as you go
0 Time limit: one hour
Test Doubles
0 Objects that mimic real objects for testing purposes
   0 Dummies
     0 Have no behaviour or throw exceptions
   0 Stubs
     0 Provide the behaviour of a real object
   0 Spies
     0 Record activity for later verification
   0 Mocks
     0 Define the expected activity before the test is run
   0 Fakes
     0 Employ a simpler implementation such as an in-memory database
0 See also
  http://martinfowler.com/articles/mocksArentStubs.html
Mocking Frameworks
0 Visual Studio doesn’t have one built-in
0 Moles
  0 Experimental framework from MS Research
0 Open source
   0 Moq, NCrunch, NMock2, Rhino Mocks, fakeiteasy
0 Commercial
   0 TypeMock Isolator, JustMock
SOLID Code
0 Single Responsibility principle
   0 An object should have only a single responsibility
0 Open/Closed principle
   0 Objects should be open for extension, but closed for modification
0 Liskov Substitution principle
   0 Objects should be replaceable with instances of their derived
     types without altering correctness
0 Interface Segregation principle
   0 Many client specific interfaces are better than one general
     purpose interface
0 Dependency Inversion principle
   0 Depend upon abstractions; do not depend upon concretions
Inversion of Control
0 Microsoft
   0 Unity
   0 Common Service Locator
0 Open source
   0 Castle Windsor, Autofac, StructureMap, Ninject, LinFu
Exercise 5
0 Create a solution with two class libraries:
   0 Translator
   0 Translator.Facts
0 Use TDD to solve the problem
  0 TODO

0 Refactor the code as you go
0 Use test doubles to isolate tests from dependencies
  and resources to achieve SOLID code
0 Time limit: two hours

Mais conteúdo relacionado

Mais procurados

Scrum and Test-driven development
Scrum and Test-driven developmentScrum and Test-driven development
Scrum and Test-driven developmenttoteb5
 
TDD (Test Driven Design)
TDD (Test Driven Design)TDD (Test Driven Design)
TDD (Test Driven Design)nedirtv
 
TDD - Test Driven Development
TDD - Test Driven DevelopmentTDD - Test Driven Development
TDD - Test Driven DevelopmentTung Nguyen Thanh
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven DevelopmentMireia Sangalo
 
Test-Driven Development (TDD)
Test-Driven Development (TDD)Test-Driven Development (TDD)
Test-Driven Development (TDD)Brian Rasmussen
 
Test-Driven Development
Test-Driven DevelopmentTest-Driven Development
Test-Driven DevelopmentJohn Blum
 
A Not-So-Serious Introduction to Test Driven Development (TDD)
A Not-So-Serious Introduction to Test Driven Development (TDD) A Not-So-Serious Introduction to Test Driven Development (TDD)
A Not-So-Serious Introduction to Test Driven Development (TDD) CodeOps Technologies LLP
 
TDD And Refactoring
TDD And RefactoringTDD And Refactoring
TDD And RefactoringNaresh Jain
 
Dependency Injection in iOS
Dependency Injection in iOSDependency Injection in iOS
Dependency Injection in iOSPablo Villar
 
A Brief Introduction to Test-Driven Development
A Brief Introduction to Test-Driven DevelopmentA Brief Introduction to Test-Driven Development
A Brief Introduction to Test-Driven DevelopmentShawn Jones
 
An Introduction to Test Driven Development
An Introduction to Test Driven Development An Introduction to Test Driven Development
An Introduction to Test Driven Development CodeOps Technologies LLP
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven DevelopmentDhaval Dalal
 
TDD Flow: The Mantra in Action
TDD Flow: The Mantra in ActionTDD Flow: The Mantra in Action
TDD Flow: The Mantra in ActionDionatan default
 
Test driven development
Test driven developmentTest driven development
Test driven developmentNascenia IT
 
ATDD in Practice
ATDD in PracticeATDD in Practice
ATDD in PracticeSteven Mak
 
Introduction to TDD (Test Driven development) - Ahmed Shreef
Introduction to TDD (Test Driven development) - Ahmed ShreefIntroduction to TDD (Test Driven development) - Ahmed Shreef
Introduction to TDD (Test Driven development) - Ahmed ShreefAhmed Shreef
 
Test Drive Development
Test Drive DevelopmentTest Drive Development
Test Drive Developmentsatya sudheer
 

Mais procurados (20)

Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
 
Scrum and Test-driven development
Scrum and Test-driven developmentScrum and Test-driven development
Scrum and Test-driven development
 
TDD (Test Driven Design)
TDD (Test Driven Design)TDD (Test Driven Design)
TDD (Test Driven Design)
 
TDD - Test Driven Development
TDD - Test Driven DevelopmentTDD - Test Driven Development
TDD - Test Driven Development
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
 
Test-Driven Development (TDD)
Test-Driven Development (TDD)Test-Driven Development (TDD)
Test-Driven Development (TDD)
 
Test-Driven Development
Test-Driven DevelopmentTest-Driven Development
Test-Driven Development
 
A Not-So-Serious Introduction to Test Driven Development (TDD)
A Not-So-Serious Introduction to Test Driven Development (TDD) A Not-So-Serious Introduction to Test Driven Development (TDD)
A Not-So-Serious Introduction to Test Driven Development (TDD)
 
TDD And Refactoring
TDD And RefactoringTDD And Refactoring
TDD And Refactoring
 
Dependency Injection in iOS
Dependency Injection in iOSDependency Injection in iOS
Dependency Injection in iOS
 
A Brief Introduction to Test-Driven Development
A Brief Introduction to Test-Driven DevelopmentA Brief Introduction to Test-Driven Development
A Brief Introduction to Test-Driven Development
 
An Introduction to Test Driven Development
An Introduction to Test Driven Development An Introduction to Test Driven Development
An Introduction to Test Driven Development
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
 
TDD Flow: The Mantra in Action
TDD Flow: The Mantra in ActionTDD Flow: The Mantra in Action
TDD Flow: The Mantra in Action
 
Test driven development
Test driven developmentTest driven development
Test driven development
 
TDD - Agile
TDD - Agile TDD - Agile
TDD - Agile
 
ATDD in Practice
ATDD in PracticeATDD in Practice
ATDD in Practice
 
Introduction to TDD (Test Driven development) - Ahmed Shreef
Introduction to TDD (Test Driven development) - Ahmed ShreefIntroduction to TDD (Test Driven development) - Ahmed Shreef
Introduction to TDD (Test Driven development) - Ahmed Shreef
 
TDD and BDD and ATDD
TDD and BDD and ATDDTDD and BDD and ATDD
TDD and BDD and ATDD
 
Test Drive Development
Test Drive DevelopmentTest Drive Development
Test Drive Development
 

Destaque

TDD Introduction with Kata FizzBuzz
TDD Introduction with Kata FizzBuzzTDD Introduction with Kata FizzBuzz
TDD Introduction with Kata FizzBuzzRick Liu
 
Your code sucks, let's fix it
Your code sucks, let's fix itYour code sucks, let's fix it
Your code sucks, let's fix itRafael Dohms
 
Test Driven Development (TDD) with FlexUnit 4 - 360|Flex San Jose preso
Test Driven Development (TDD) with FlexUnit 4 - 360|Flex San Jose presoTest Driven Development (TDD) with FlexUnit 4 - 360|Flex San Jose preso
Test Driven Development (TDD) with FlexUnit 4 - 360|Flex San Jose presoElad Elrom
 
Implementing DDD with C#
Implementing DDD with C#Implementing DDD with C#
Implementing DDD with C#Pascal Laurin
 
The WHY behind TDD/BDD and the HOW with RSpec
The WHY behind TDD/BDD and the HOW with RSpecThe WHY behind TDD/BDD and the HOW with RSpec
The WHY behind TDD/BDD and the HOW with RSpecBen Mabey
 
Test and Behaviour Driven Development (TDD/BDD)
Test and Behaviour Driven Development (TDD/BDD)Test and Behaviour Driven Development (TDD/BDD)
Test and Behaviour Driven Development (TDD/BDD)Lars Thorup
 
Selenium WebDriver with C#
Selenium WebDriver with C#Selenium WebDriver with C#
Selenium WebDriver with C#srivinayak
 
Overview on TDD (Test Driven Development) & ATDD (Acceptance Test Driven Deve...
Overview on TDD (Test Driven Development) & ATDD (Acceptance Test Driven Deve...Overview on TDD (Test Driven Development) & ATDD (Acceptance Test Driven Deve...
Overview on TDD (Test Driven Development) & ATDD (Acceptance Test Driven Deve...Zohirul Alam Tiemoon
 
7 astuces pour améliorer vos tests unitaires
7 astuces pour améliorer vos tests unitaires7 astuces pour améliorer vos tests unitaires
7 astuces pour améliorer vos tests unitairesPascal Laurin
 
L'amélioration des tests unitaires par le refactoring
L'amélioration des tests unitaires par le refactoringL'amélioration des tests unitaires par le refactoring
L'amélioration des tests unitaires par le refactoringPascal Laurin
 
Tests automatisés java script
Tests automatisés java scriptTests automatisés java script
Tests automatisés java scriptPascal Laurin
 

Destaque (16)

C# 6
C# 6C# 6
C# 6
 
TDD Introduction with Kata FizzBuzz
TDD Introduction with Kata FizzBuzzTDD Introduction with Kata FizzBuzz
TDD Introduction with Kata FizzBuzz
 
Introduction to TDD
Introduction to TDDIntroduction to TDD
Introduction to TDD
 
Tdd - introduction
Tdd - introductionTdd - introduction
Tdd - introduction
 
Your code sucks, let's fix it
Your code sucks, let's fix itYour code sucks, let's fix it
Your code sucks, let's fix it
 
Introduction to TDD and Mocking
Introduction to TDD and MockingIntroduction to TDD and Mocking
Introduction to TDD and Mocking
 
Test Driven Development (TDD) with FlexUnit 4 - 360|Flex San Jose preso
Test Driven Development (TDD) with FlexUnit 4 - 360|Flex San Jose presoTest Driven Development (TDD) with FlexUnit 4 - 360|Flex San Jose preso
Test Driven Development (TDD) with FlexUnit 4 - 360|Flex San Jose preso
 
Implementing DDD with C#
Implementing DDD with C#Implementing DDD with C#
Implementing DDD with C#
 
TDD Overview
TDD OverviewTDD Overview
TDD Overview
 
The WHY behind TDD/BDD and the HOW with RSpec
The WHY behind TDD/BDD and the HOW with RSpecThe WHY behind TDD/BDD and the HOW with RSpec
The WHY behind TDD/BDD and the HOW with RSpec
 
Test and Behaviour Driven Development (TDD/BDD)
Test and Behaviour Driven Development (TDD/BDD)Test and Behaviour Driven Development (TDD/BDD)
Test and Behaviour Driven Development (TDD/BDD)
 
Selenium WebDriver with C#
Selenium WebDriver with C#Selenium WebDriver with C#
Selenium WebDriver with C#
 
Overview on TDD (Test Driven Development) & ATDD (Acceptance Test Driven Deve...
Overview on TDD (Test Driven Development) & ATDD (Acceptance Test Driven Deve...Overview on TDD (Test Driven Development) & ATDD (Acceptance Test Driven Deve...
Overview on TDD (Test Driven Development) & ATDD (Acceptance Test Driven Deve...
 
7 astuces pour améliorer vos tests unitaires
7 astuces pour améliorer vos tests unitaires7 astuces pour améliorer vos tests unitaires
7 astuces pour améliorer vos tests unitaires
 
L'amélioration des tests unitaires par le refactoring
L'amélioration des tests unitaires par le refactoringL'amélioration des tests unitaires par le refactoring
L'amélioration des tests unitaires par le refactoring
 
Tests automatisés java script
Tests automatisés java scriptTests automatisés java script
Tests automatisés java script
 

Semelhante a Test Driven Development (C#)

49.INS2065.Computer Based Technologies.TA.NguyenDucAnh.pdf
49.INS2065.Computer Based Technologies.TA.NguyenDucAnh.pdf49.INS2065.Computer Based Technologies.TA.NguyenDucAnh.pdf
49.INS2065.Computer Based Technologies.TA.NguyenDucAnh.pdfcNguyn506241
 
Dev trends 18_q1
Dev trends 18_q1Dev trends 18_q1
Dev trends 18_q1Pini Cohen
 
Design Patterns - General Introduction
Design Patterns - General IntroductionDesign Patterns - General Introduction
Design Patterns - General IntroductionAsma CHERIF
 
Microservices: Why and When? - Alon Fliess, CodeValue - Cloud Native Day Tel ...
Microservices: Why and When? - Alon Fliess, CodeValue - Cloud Native Day Tel ...Microservices: Why and When? - Alon Fliess, CodeValue - Cloud Native Day Tel ...
Microservices: Why and When? - Alon Fliess, CodeValue - Cloud Native Day Tel ...Cloud Native Day Tel Aviv
 
Software Architecture for Agile Development
Software Architecture for Agile DevelopmentSoftware Architecture for Agile Development
Software Architecture for Agile DevelopmentHayim Makabee
 
Developer Experience (DX) for UX Professionals
Developer Experience (DX) for UX ProfessionalsDeveloper Experience (DX) for UX Professionals
Developer Experience (DX) for UX ProfessionalsIan Jennings
 
Matteo Gazzurelli - Andorid introduction - Google Dev Fest 2013
Matteo Gazzurelli - Andorid introduction - Google Dev Fest 2013Matteo Gazzurelli - Andorid introduction - Google Dev Fest 2013
Matteo Gazzurelli - Andorid introduction - Google Dev Fest 2013DuckMa
 
WDS trainer presentation - MLOps.pptx
WDS trainer presentation - MLOps.pptxWDS trainer presentation - MLOps.pptx
WDS trainer presentation - MLOps.pptxArthur240715
 
The absolute minimum 10 things for technical writers
The absolute minimum 10 things for technical writersThe absolute minimum 10 things for technical writers
The absolute minimum 10 things for technical writersRaghunath (Gautam) Soman
 
Sofwear deasign and need of design pattern
Sofwear deasign and need of design patternSofwear deasign and need of design pattern
Sofwear deasign and need of design patternchetankane
 
Choosing an Open Source CMS
Choosing an Open Source CMSChoosing an Open Source CMS
Choosing an Open Source CMSPhase2
 
From silex to symfony and viceversa
From silex to symfony and viceversaFrom silex to symfony and viceversa
From silex to symfony and viceversaRonny López
 
Integrating Machine Learning Capabilities into your team
Integrating Machine Learning Capabilities into your teamIntegrating Machine Learning Capabilities into your team
Integrating Machine Learning Capabilities into your teamCameron Vetter
 
From DevOps to NoOps
From DevOps to NoOpsFrom DevOps to NoOps
From DevOps to NoOpsCapgemini
 
3.o o design -_____________lecture 3
3.o o design -_____________lecture 33.o o design -_____________lecture 3
3.o o design -_____________lecture 3Warui Maina
 
A-Hospital-Management-System Shanto , waliul , Turjo , Munna- FULL update 2 ...
A-Hospital-Management-System Shanto  , waliul , Turjo , Munna- FULL update 2 ...A-Hospital-Management-System Shanto  , waliul , Turjo , Munna- FULL update 2 ...
A-Hospital-Management-System Shanto , waliul , Turjo , Munna- FULL update 2 ...ShahriaShanto
 

Semelhante a Test Driven Development (C#) (20)

OO design principles and patterns
OO design principles and patternsOO design principles and patterns
OO design principles and patterns
 
Design patterns
Design patternsDesign patterns
Design patterns
 
49.INS2065.Computer Based Technologies.TA.NguyenDucAnh.pdf
49.INS2065.Computer Based Technologies.TA.NguyenDucAnh.pdf49.INS2065.Computer Based Technologies.TA.NguyenDucAnh.pdf
49.INS2065.Computer Based Technologies.TA.NguyenDucAnh.pdf
 
Dev trends 18_q1
Dev trends 18_q1Dev trends 18_q1
Dev trends 18_q1
 
Design Patterns
Design PatternsDesign Patterns
Design Patterns
 
Design Patterns - General Introduction
Design Patterns - General IntroductionDesign Patterns - General Introduction
Design Patterns - General Introduction
 
Ds for finance day 4
Ds for finance day 4Ds for finance day 4
Ds for finance day 4
 
Microservices: Why and When? - Alon Fliess, CodeValue - Cloud Native Day Tel ...
Microservices: Why and When? - Alon Fliess, CodeValue - Cloud Native Day Tel ...Microservices: Why and When? - Alon Fliess, CodeValue - Cloud Native Day Tel ...
Microservices: Why and When? - Alon Fliess, CodeValue - Cloud Native Day Tel ...
 
Software Architecture for Agile Development
Software Architecture for Agile DevelopmentSoftware Architecture for Agile Development
Software Architecture for Agile Development
 
Developer Experience (DX) for UX Professionals
Developer Experience (DX) for UX ProfessionalsDeveloper Experience (DX) for UX Professionals
Developer Experience (DX) for UX Professionals
 
Matteo Gazzurelli - Andorid introduction - Google Dev Fest 2013
Matteo Gazzurelli - Andorid introduction - Google Dev Fest 2013Matteo Gazzurelli - Andorid introduction - Google Dev Fest 2013
Matteo Gazzurelli - Andorid introduction - Google Dev Fest 2013
 
WDS trainer presentation - MLOps.pptx
WDS trainer presentation - MLOps.pptxWDS trainer presentation - MLOps.pptx
WDS trainer presentation - MLOps.pptx
 
The absolute minimum 10 things for technical writers
The absolute minimum 10 things for technical writersThe absolute minimum 10 things for technical writers
The absolute minimum 10 things for technical writers
 
Sofwear deasign and need of design pattern
Sofwear deasign and need of design patternSofwear deasign and need of design pattern
Sofwear deasign and need of design pattern
 
Choosing an Open Source CMS
Choosing an Open Source CMSChoosing an Open Source CMS
Choosing an Open Source CMS
 
From silex to symfony and viceversa
From silex to symfony and viceversaFrom silex to symfony and viceversa
From silex to symfony and viceversa
 
Integrating Machine Learning Capabilities into your team
Integrating Machine Learning Capabilities into your teamIntegrating Machine Learning Capabilities into your team
Integrating Machine Learning Capabilities into your team
 
From DevOps to NoOps
From DevOps to NoOpsFrom DevOps to NoOps
From DevOps to NoOps
 
3.o o design -_____________lecture 3
3.o o design -_____________lecture 33.o o design -_____________lecture 3
3.o o design -_____________lecture 3
 
A-Hospital-Management-System Shanto , waliul , Turjo , Munna- FULL update 2 ...
A-Hospital-Management-System Shanto  , waliul , Turjo , Munna- FULL update 2 ...A-Hospital-Management-System Shanto  , waliul , Turjo , Munna- FULL update 2 ...
A-Hospital-Management-System Shanto , waliul , Turjo , Munna- FULL update 2 ...
 

Mais de Alan Dean

Test Driven Development (Delphi)
Test Driven Development (Delphi)Test Driven Development (Delphi)
Test Driven Development (Delphi)Alan Dean
 
Azure, Cloud Computing & Services
Azure, Cloud Computing & ServicesAzure, Cloud Computing & Services
Azure, Cloud Computing & ServicesAlan Dean
 
Separating REST Facts from Fallacies
Separating REST Facts from FallaciesSeparating REST Facts from Fallacies
Separating REST Facts from FallaciesAlan Dean
 
Future Direction For Agile
Future Direction For AgileFuture Direction For Agile
Future Direction For AgileAlan Dean
 
Introduction To ASP.NET MVC
Introduction To ASP.NET MVCIntroduction To ASP.NET MVC
Introduction To ASP.NET MVCAlan Dean
 
Object Thinking
Object ThinkingObject Thinking
Object ThinkingAlan Dean
 
Internationalisation And Globalisation
Internationalisation And GlobalisationInternationalisation And Globalisation
Internationalisation And GlobalisationAlan Dean
 

Mais de Alan Dean (8)

Cavity Data
Cavity DataCavity Data
Cavity Data
 
Test Driven Development (Delphi)
Test Driven Development (Delphi)Test Driven Development (Delphi)
Test Driven Development (Delphi)
 
Azure, Cloud Computing & Services
Azure, Cloud Computing & ServicesAzure, Cloud Computing & Services
Azure, Cloud Computing & Services
 
Separating REST Facts from Fallacies
Separating REST Facts from FallaciesSeparating REST Facts from Fallacies
Separating REST Facts from Fallacies
 
Future Direction For Agile
Future Direction For AgileFuture Direction For Agile
Future Direction For Agile
 
Introduction To ASP.NET MVC
Introduction To ASP.NET MVCIntroduction To ASP.NET MVC
Introduction To ASP.NET MVC
 
Object Thinking
Object ThinkingObject Thinking
Object Thinking
 
Internationalisation And Globalisation
Internationalisation And GlobalisationInternationalisation And Globalisation
Internationalisation And Globalisation
 

Último

Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfSeasiaInfotech2
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 

Último (20)

Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdf
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 

Test Driven Development (C#)

  • 1.
  • 3. Plan-Do-Check-Act 0 Originally called Plan-Do-Study-Act 0 Created by Walter Shewhart at Bell Labs during the 1930s
  • 4. Iterative & Incremental Development 0 The X-15 program in the 1950s used IID
  • 5. Test-First in the Swinging 60s 0 X-15 team members seeded Project Mercury 0 Time-boxed half-day iterations 0 Tests were written first 0 Reviews after each iteration 0 Top-down development with stubs
  • 6. We were doing incremental development as early as 1957, in Los Angeles, under the direction of Bernie Dimsdale [at IBM’s Service Bureau Corporation]. He was a colleague of John von Neumann, so perhaps he learned it there, or assumed it as totally natural. I do remember Herb Jacobs (primarily, though we all participated) developing a large simulation for Motorola, where the technique used was, as far as I can tell, indistinguishable from XP. When much of the same team was reassembled in Washington, DC in 1958 to develop Project Mercury, we had our own machine and the new Share Operating System, whose symbolic modification and assembly allowed us to build the system incrementally, which we did, with great success. Project Mercury was the seed bed out of which grew the IBM Federal Systems Division. Thus, that division started with a history and tradition of incremental development. All of us, as far as I can remember, thought waterfalling of a huge project was rather stupid, or at least ignorant of the realities… I think what the waterfall description did for us was make us realize that we were doing something else, something unnamed except for “software development.” Gerald M. Weinberg
  • 7. Waterfall in the 1970s & 80s 0 Blame the DoD and the CMMI
  • 8. Other stuff was happening 0 Object-orientation 0 Simula from the late 60s 0 Smalltalk in the 70s at Xerox PARC 0 Software distribution
  • 9. Into the 1990s 0 UML evolves 0 www arrives
  • 10. What RUP was meant to be
  • 17. Agile is just XP, rebadged
  • 20. The Testing Game 0 Red: 0 “Write a failing test” 0 Green: 0 “Pass the failing test” 0 Refactor 0 “Clean the implementation”
  • 21. Write a failing test 0 To know what test to write, you must: 0 Analyze your problem 0 Design your solution 0 Code intentionally 0 To dislike “Big Upfront Design” is not to dislike design
  • 22. Agile Problem Analysis 0 System Metaphor 0 Arises from the Architectural Spike 0 A simple design with the defining quality of explaining the system design without reference to documents 0 User Experience 0 Arises from the set of all user stories 0 Provides a canvas onto which individual stories can be painted 0 User Story 0 Describes a specific user expectation 0 Provides the functional constraints of implementation
  • 23. User Stories 0 A user story comprises one or more sentences in the everyday or business language of the end user that captures what the user wants to achieve
  • 24. Agile Solutions 0 “Walk the solution”: for each user story 0 Understand how this fits into the user experience 0 Understand where the necessary functional implementation goes in the architecture 0 Design the functional implementation
  • 25. Goldilocks Design 0 Design only what you need 0 avoid YAGNI (You Ain’t Gonna Need It) 0 Reuse existing implementation 0 be DRY (Don’t Repeat Yourself) 0 Prefer sketched designs over definitive design 0 allow TDD to be part of your design process 0 Don’t experiment in code 0 use spikes where necessary
  • 26. First Exercise 0 Brainstorm a realistic candidate application 0 Write a small set of user stories 0 Elaborate a user experience 0 Articulate a system metaphor 0 Time limit: one hour
  • 27. Analysis & Design 0 There are a variety of approaches to functional analysis and implementation design 0 The most commonly used are: 0 The UML 0 CRC Cards 0 Design Patterns 0 Linguistics & Semantics 0 Personas 0 Storyboards
  • 28. UML 0 The UML (Unified Modeling Language) 0 It has the advantage that many developers have at least some familiarity 0 It has the disadvantage of significant complexity 0 Most agile practitioners use ‘sketch’ UML, typically on a whiteboard, in order to convey a mental model of a proposed solution 0 Be indicative, not definitive
  • 29. UML Use Case Diagram 0 Describes the functionality provided by a system in terms of actors and their goals represented as use cases
  • 30. UML Activity Diagram 0 Used to describe the business and operational step-by-step workflows of components in a system
  • 31. UML Sequence Diagram 0 Shows how processes operate with one another and in what sequence
  • 32. UML Class Diagram 0 Describes the structure of a system by showing the system's classes, their attributes, methods, and the relationships among the classes
  • 33. CRC Cards 0 Class Responsibility Collaboration cards are a brainstorming tool, proposed by Ward Cunningham and Kent Beck 0 They are typically used when determining which classes are needed and how they will interact 0 CRC cards are usually created from index cards on which are written: 0 The class name 0 Any base or derived classes (if applicable) 0 The responsibilities of the class 0 The names of other classes with which the class will collaborate to fulfil its responsibilities
  • 35. Design Patterns 0 A general reusable solution to a commonly occurring problem within a given context 0 A design pattern is not a finished design that can be transformed directly into code; it is a description or template for how to solve a problem that can be used in many different situations 0 Typically show relationships and interactions between classes or objects, without specifying the final application classes or objects that are involved
  • 36. Some Creational Patterns 0 Factory method 0 Define an interface for creating an object, but let derived classes decide which class to instantiate 0 Lazy initialization 0 Tactic of delaying the creation of an object, the calculation of a value, or some other expensive process until the first time it is needed 0 Object pool 0 Avoid expensive acquisition and release of resources by recycling objects that are no longer in use 0 Resource acquisition is initialization 0 Ensure that resources are properly released by tying them to the lifespan of suitable objects 0 Singleton 0 Ensure a class has only one instance, and provide a global point of access to it
  • 37. Some Structural Patterns 0 Adapter 0 Convert the interface of a class into another interface clients expect 0 Bridge 0 Decouple an abstraction from its implementation allowing the two to vary independently 0 Facade 0 Provide a unified interface to a set of interfaces in a subsystem 0 Proxy 0 Provide a surrogate or placeholder for another object to control access to it
  • 38. Some Behavioural Patterns 0 Chain of responsibility 0 Avoid coupling the sender of a request to its receiver by giving more than one object a chance to handle the request 0 Command 0 Encapsulate a request as an object, thereby letting you parameterize clients with different requests, queue or log requests, and support undoable operations 0 Iterator 0 Provide a way to access the elements of an aggregate object sequentially without exposing its underlying representation 0 Null object 0 Avoid null references by providing a default object
  • 39. Linguistics & Semantics 0 Using the meanings and relationships of words and phrases employed in the user stories and other material to construct a language map of the problem domain 0 Especially useful when dealing with ‘expert’ systems
  • 40. Personas 0 Fictional characters created to represent the different user types within a targeted demographic, attitude and/or behaviour set that might use a site, brand or product in a similar way
  • 41. Storyboards 0 A technique borrowed from the film industry 0 Shows the user experience in sequence
  • 42. Second Exercise 0 Take one or more of the user stories from the first exercise and apply a selection of the analysis and design techniques 0 Draw up a list of the strengths and weaknesses of the techniques in relation to these particular user stories 0 Time limit: one hour
  • 43. Testing Frameworks 0 MSTest 0 Built-in to Visual Studio 0 Pex 0 Experimental white-box testing from MS Research 0 NUnit 0 Early open source port of JUnit for .net 0 MbUnit 0 Another open source framework 0 xUnit 0 Open source reset of NUnit 0 SpecFlow 0 Open source behaviour-driven-development framework
  • 44. Arrange, Act, Assert 0 The default pattern for unit tests 1. Arrange all necessary preconditions and inputs 2. Act on the object or method under test 3. Assert that the expected results have occurred
  • 45. Test naming conventions 0 Ad-hoc 0 Anything goes 0 Behavioural 0 Tests are named according to the behaviour under test 0 Good fit for collaboration tests (distinct from unit tests) public void customer_pays_in_cheque_to_current_account() 0 Contractual 0 Names follow the unit contract under test http://alandean.blogspot.com/2011/11/unit-test-naming-convention.html
  • 46. xUnit Assertions 0 Fundamentals 0 Assert.True(…) or Assert.False(…) 0 Assert.Null(…) or Assert.NotNull(…) 0 Assert.Equal(…) or Assert.NotEqual(…) 0 Assert.Same(…) or Assert.NotSame(…) 0 Exceptions 0 Assert.Throws<T>(…) or Assert.DoesNotThrow(…) 0 Type checks 0 Assert.IsType(…) or Assert.IsNotType<T>(…) 0 Assert.IsAssignableFrom<T>(…) 0 IEnumerable 0 Assert.Empty(…) or Assert.NotEmpty(…) 0 Assert.Single(…) 0 Assert.Contains(…) or Assert.DoesNotContain(…) 0 Assert.InRange(…) or Assert.NotInRange(…)
  • 47. System.Diagnostics.Debug 0 Assertions 0 Debug.Assert(…) 0 Debug.Fail(…) 0 Publication 0 Debug.Print(…) 0 Debug.Write(…) or Debug.WriteIf(…) 0 Debug.WriteLine(…) or Debug.WriteLineIf(…)
  • 48. TDD at the Keyboard 1. Add a new test 2. Run all tests and see if the new one fails 3. Write some code 4. Run all tests and see them succeed 5. Refactor code 6. Repeat
  • 49. Exercise 3 0 Create a solution with two class libraries: 0 TicTacToe 0 TicTacToe.Facts 0 Add a reference to xUnit.net in the Facts library 0 http://nuget.org/ 0 Use TDD to implement Tic-Tac-Toe 0 http://gojko.net/2009/08/02/tdd-as-if-you-meant-it-revisited/ 0 Time limit: one hour
  • 50. Refactoring Code 0 A disciplined technique for restructuring an existing body of code, altering its internal structure without changing its external behaviour 0 Usually motivated by noticing a code smell 0 There are two general categories of benefits to the activity of refactoring 0 Maintainability 0 It is easier to fix bugs because the source code is easy to read and the intent of its author is easy to grasp 0 This might be achieved by reducing large monolithic routines into a set of individually concise, well-named, single-purpose methods 0 It might be achieved by moving a method to a more appropriate class, or by removing misleading comments. 0 Extensibility 0 It is easier to extend the capabilities of the application if it uses recognizable design patterns, and it provides some flexibility where none before may have existed
  • 51. Refactoring Techniques 0 Techniques that allow for more abstraction 0 Encapsulate Field: force code to access the field with getter and setter methods 0 Generalize Type: create more general types to allow for more code sharing 0 Replace Conditional with Polymorphism: move each leg of the conditional to an overriding method in a derived class and make the original method abstract 0 Techniques for breaking code apart into more logical pieces 0 Extract Method: turn part of a larger method into a new method 0 Extract Class: moves part of the code from an existing class into a new class 0 Techniques for improving names and location of code 0 Move Method or Field: move to a more appropriate class 0 Rename Method or Field: changing the name to one that better reveals its purpose 0 Pull Up: move to a base class 0 Push Down: move to a derived class 0 Longer list 0 http://martinfowler.com/refactoring/catalog/index.html
  • 52. Exercise 4 0 Create a solution with two class libraries: 0 RomanNumerals 0 RomanNumerals.Facts 0 Use TDD to solve the problem 0 https://sites.google.com/site/tddproblems/all-problems-1/Roman-number-conversion 0 Refactor the code as you go 0 Time limit: one hour
  • 53. Test Doubles 0 Objects that mimic real objects for testing purposes 0 Dummies 0 Have no behaviour or throw exceptions 0 Stubs 0 Provide the behaviour of a real object 0 Spies 0 Record activity for later verification 0 Mocks 0 Define the expected activity before the test is run 0 Fakes 0 Employ a simpler implementation such as an in-memory database 0 See also http://martinfowler.com/articles/mocksArentStubs.html
  • 54. Mocking Frameworks 0 Visual Studio doesn’t have one built-in 0 Moles 0 Experimental framework from MS Research 0 Open source 0 Moq, NCrunch, NMock2, Rhino Mocks, fakeiteasy 0 Commercial 0 TypeMock Isolator, JustMock
  • 55. SOLID Code 0 Single Responsibility principle 0 An object should have only a single responsibility 0 Open/Closed principle 0 Objects should be open for extension, but closed for modification 0 Liskov Substitution principle 0 Objects should be replaceable with instances of their derived types without altering correctness 0 Interface Segregation principle 0 Many client specific interfaces are better than one general purpose interface 0 Dependency Inversion principle 0 Depend upon abstractions; do not depend upon concretions
  • 56. Inversion of Control 0 Microsoft 0 Unity 0 Common Service Locator 0 Open source 0 Castle Windsor, Autofac, StructureMap, Ninject, LinFu
  • 57. Exercise 5 0 Create a solution with two class libraries: 0 Translator 0 Translator.Facts 0 Use TDD to solve the problem 0 TODO 0 Refactor the code as you go 0 Use test doubles to isolate tests from dependencies and resources to achieve SOLID code 0 Time limit: two hours