SlideShare uma empresa Scribd logo
1 de 13
Testing . NET systems using F#
HOW LONG WILL IT TAKE YOU?
@RBARTELINK
DUBLIN ALT.NET
24 OCTOBER, 2013
The test pyramid
 It’s not easy to achieve a good balance in a set of tests
 Too much AT -> slow + doesn’t drive implementation properly
 Too much UT -> Not meeting Living Documentation aim
 One size won’t fit all

http://martinfowler.com/bliki/TestPyramid.html (originated by Mike Cohn)
ATDD workflow

http://www.infoq.com/articles/atdd-from-the-trenches
Why?
 You need to express high and low level tests
 MbUnit, Sub/N/M/Spec are single paradigm
 3 year old tests are uglier than 3yo production code
 Test code is just different to production code
 Learn a language a year
 F# has been in VS since 2009
 One of F#’s many paradigms is to be a better C#
What can I use
 Everything (yes, everything) you know
 NUnit, MSpec, SpecFlow
 FluentAssertions,
 RhinoMocks, FakeItEasy, NSubstitute
 Things you’re already using
 xUnit.net, LINQ, Moq
 Modern Libs
 AutoFixture, AutoFixture.xUnit, AutoFixture.AutoMoq
 Foq, AutoFixture.AutoFoq
 TickSpec
Gherkin
 Feature files (Gherkin)
Feature: Addition
In order to avoid silly mistakes
As a math idiot
I want to be told the sum of two numbers
Scenario: Add two numbers
When I add 2 and 2
Then I should see 4
TickSpec
 TickFacts
[<TickFact>] let AdditionFeature () =
EmbeddedResourceFeatures.ScenariosFrom “Addition"

 Step Definitions (TickSpec with unquote)
module CalculatorSteps =
[<When>] ``I add (.*) and (.*)`` x y =
result <- Calculator()
|> enter x |> plus |> enter y
|> compute
[<Then>] ``I should see (.*)`` expected =
test <@ expected = result @>
Gherkin Backgrounds and Outlines
Feature: Addition
Background:
Given I switch my calculator to fancy mode
Scenario Outline: The Hard Stuff
When I add <First> and <Second>
Then I should see <Total>
Examples:
|First|Second|Total|
|1
|1
|2
|
|9
|-1
|8
|
Unit Testing
 Tick methods (xUnit/NUnit with unquote)
module CalculatorFacts =
[<Fact>] let ``Adding two small ints works`` () =
let result = Calculator() |> enter 2 |> plus |> enter 2 |> compute

test <@ 2+2 = result @>

 Mocking DSLs (Foq)
Mock<IList<char>>.With(fun x ->
<@ x.Count --> 2
x.Item(0) --> '0'
x.Item(1) --> '1'
x.Contains( any() ) --> true
x.RemoveAt( 2) ==> System.ArgumentOutOfRangeException()
@>)
Low Level Stuff
Type inference any()
(for real)

It.IsAny<DateTime>()

mock()

Mock.Of<T>

Tuples

let tuple = key,value
let _,value = tuple

var tuple = Tuple.Create( key, value)
var value = tuple.Item2

Lambdas

let gen a b = CreateSut a b |> Fill
let gen = CreateSut >> Fill

var gen = (int a, int b) =>
CreateSut( a, b).Fill()

Object
Expressions

let time = { new ITime with
member mock.GetHour() = 15}

class FakeTime15 {int GetHour() { return
15;}}
var time = new FakeTime15()

Custom ops

expected =? Actual // From unquote

Asset.Equal( expected, actual)

Quotations

test <@ expected =
result |> String.Concat “,” @>

Assert.That( expected, Is.EqualTo(
String.Concat( “,”, result)));

let list = Mock<IList>
.Method(fun x -> <@ x.Contains @>)
.Returns( true)

var mock = new Mock<IList>();
mock.Setup( x=> x
.Contains( It.IsAny<object>())
.Returns( true)
The bad points
 Need to install FSC on CI server (2 clicks or 11 MB






MSI or put FSC in tools dir Just Works)
You can’t mix F# and C# in a single project
F12 from F# to/from C# doesn’t work (but built in
Ctrl-, and F12 within files is fine)
No refactoring support of consequence (but not as
important as you think)
C# starts to grate a little more every day (as does “in
F# you can just…”)
Books
 Growing Object Oriented Software, Guided by Tests





(Freeman, Pryce)
Specification By Example (Adzic)
The RSpec book (Chelimsky et al)
Expert F# 3 (Syme)
Real World Functional Programming in F# and C#
(Petricek, Skeet)
Resources
 F#
 @ptrelford http://trelford.com/blog and samples
 SO F# tag
 Google
 @tomaspetricek http://tomasp.net/blog/
 Don’t forget MSDN
 ATDD
 GOOS
 @ploeh Outside In Test Driven Development
http://pluralsight.com/training/Courses/TableOfContents/ou
tside-in-tdd

Mais conteúdo relacionado

Mais procurados

Operators and Control Statements in Python
Operators and Control Statements in PythonOperators and Control Statements in Python
Operators and Control Statements in PythonRajeswariA8
 
Python quickstart for programmers: Python Kung Fu
Python quickstart for programmers: Python Kung FuPython quickstart for programmers: Python Kung Fu
Python quickstart for programmers: Python Kung Fuclimatewarrior
 
Iterarators and generators in python
Iterarators and generators in pythonIterarators and generators in python
Iterarators and generators in pythonSarfaraz Ghanta
 
F# Eye 4 the C# Guy - DDD Cambridge Nights 2014
F# Eye 4 the C# Guy -  DDD Cambridge Nights 2014F# Eye 4 the C# Guy -  DDD Cambridge Nights 2014
F# Eye 4 the C# Guy - DDD Cambridge Nights 2014Phillip Trelford
 
Introduction to Python Programming
Introduction to Python ProgrammingIntroduction to Python Programming
Introduction to Python ProgrammingVijaySharma802
 
13 Strings and Text Processing
13 Strings and Text Processing13 Strings and Text Processing
13 Strings and Text ProcessingIntro C# Book
 
Python programming workshop session 1
Python programming workshop session 1Python programming workshop session 1
Python programming workshop session 1Abdul Haseeb
 
GE8151 Problem Solving and Python Programming
GE8151 Problem Solving and Python ProgrammingGE8151 Problem Solving and Python Programming
GE8151 Problem Solving and Python ProgrammingMuthu Vinayagam
 
Python Functions Tutorial | Working With Functions In Python | Python Trainin...
Python Functions Tutorial | Working With Functions In Python | Python Trainin...Python Functions Tutorial | Working With Functions In Python | Python Trainin...
Python Functions Tutorial | Working With Functions In Python | Python Trainin...Edureka!
 
Advance python programming
Advance python programming Advance python programming
Advance python programming Jagdish Chavan
 
Python programming Workshop SITTTR - Kalamassery
Python programming Workshop SITTTR - KalamasseryPython programming Workshop SITTTR - Kalamassery
Python programming Workshop SITTTR - KalamasserySHAMJITH KM
 
Python for data science by www.dmdiploma.com
Python for data science by www.dmdiploma.comPython for data science by www.dmdiploma.com
Python for data science by www.dmdiploma.comShwetaAggarwal56
 

Mais procurados (20)

Stacks
StacksStacks
Stacks
 
Operators and Control Statements in Python
Operators and Control Statements in PythonOperators and Control Statements in Python
Operators and Control Statements in Python
 
C Programming Homework Help
C Programming Homework HelpC Programming Homework Help
C Programming Homework Help
 
Loops in Python
Loops in PythonLoops in Python
Loops in Python
 
Python programming
Python  programmingPython  programming
Python programming
 
Python quickstart for programmers: Python Kung Fu
Python quickstart for programmers: Python Kung FuPython quickstart for programmers: Python Kung Fu
Python quickstart for programmers: Python Kung Fu
 
Iterarators and generators in python
Iterarators and generators in pythonIterarators and generators in python
Iterarators and generators in python
 
F# Eye 4 the C# Guy - DDD Cambridge Nights 2014
F# Eye 4 the C# Guy -  DDD Cambridge Nights 2014F# Eye 4 the C# Guy -  DDD Cambridge Nights 2014
F# Eye 4 the C# Guy - DDD Cambridge Nights 2014
 
Introduction to Python Programming
Introduction to Python ProgrammingIntroduction to Python Programming
Introduction to Python Programming
 
13 Strings and Text Processing
13 Strings and Text Processing13 Strings and Text Processing
13 Strings and Text Processing
 
Python programming workshop session 1
Python programming workshop session 1Python programming workshop session 1
Python programming workshop session 1
 
GE8151 Problem Solving and Python Programming
GE8151 Problem Solving and Python ProgrammingGE8151 Problem Solving and Python Programming
GE8151 Problem Solving and Python Programming
 
Python Loop
Python LoopPython Loop
Python Loop
 
Python Functions Tutorial | Working With Functions In Python | Python Trainin...
Python Functions Tutorial | Working With Functions In Python | Python Trainin...Python Functions Tutorial | Working With Functions In Python | Python Trainin...
Python Functions Tutorial | Working With Functions In Python | Python Trainin...
 
F# 101
F# 101F# 101
F# 101
 
Advance python programming
Advance python programming Advance python programming
Advance python programming
 
Python programming Workshop SITTTR - Kalamassery
Python programming Workshop SITTTR - KalamasseryPython programming Workshop SITTTR - Kalamassery
Python programming Workshop SITTTR - Kalamassery
 
C Assignment Help
C Assignment HelpC Assignment Help
C Assignment Help
 
Python for data science by www.dmdiploma.com
Python for data science by www.dmdiploma.comPython for data science by www.dmdiploma.com
Python for data science by www.dmdiploma.com
 
10. Recursion
10. Recursion10. Recursion
10. Recursion
 

Destaque

Domain Driven Design with the F# type System -- F#unctional Londoners 2014
Domain Driven Design with the F# type System -- F#unctional Londoners 2014Domain Driven Design with the F# type System -- F#unctional Londoners 2014
Domain Driven Design with the F# type System -- F#unctional Londoners 2014Scott Wlaschin
 
5 Best Practices For F# Development
5 Best Practices For F# Development5 Best Practices For F# Development
5 Best Practices For F# Developmentdmohl
 
Railway Oriented Programming
Railway Oriented ProgrammingRailway Oriented Programming
Railway Oriented ProgrammingScott Wlaschin
 
Tata Communications Network Overview
Tata Communications Network OverviewTata Communications Network Overview
Tata Communications Network Overviewwkolman
 
Trinity Kings World Leadership is the foundation for all Leadership, anything...
Trinity Kings World Leadership is the foundation for all Leadership, anything...Trinity Kings World Leadership is the foundation for all Leadership, anything...
Trinity Kings World Leadership is the foundation for all Leadership, anything...Terrell Patillo
 
Linked Open Data - A Means for Public Sector Information Management
Linked Open Data - A Means for Public Sector Information ManagementLinked Open Data - A Means for Public Sector Information Management
Linked Open Data - A Means for Public Sector Information ManagementJohann Höchtl
 
The Saints by Joe McFadden
The Saints by Joe McFaddenThe Saints by Joe McFadden
The Saints by Joe McFaddenCachi Chien
 
Quick Look Video 01 29 11 Ws
Quick Look Video 01 29 11 WsQuick Look Video 01 29 11 Ws
Quick Look Video 01 29 11 WsJohnHoke
 
Trinity Kings World Leadership: Family Franchising Systems: City of Dallas, TX
Trinity Kings World Leadership: Family Franchising Systems: City of Dallas, TXTrinity Kings World Leadership: Family Franchising Systems: City of Dallas, TX
Trinity Kings World Leadership: Family Franchising Systems: City of Dallas, TXTerrell Patillo
 
Estudo de ROI com LotusLive Para efeito de Demonstração
Estudo de ROI com LotusLive Para efeito de DemonstraçãoEstudo de ROI com LotusLive Para efeito de Demonstração
Estudo de ROI com LotusLive Para efeito de DemonstraçãoWashington Cabral
 
130315 HCD-Netにおける資格認定制度 (英文 certification system of hcd net)
130315 HCD-Netにおける資格認定制度 (英文 certification system of hcd net)130315 HCD-Netにおける資格認定制度 (英文 certification system of hcd net)
130315 HCD-Netにおける資格認定制度 (英文 certification system of hcd net)Masaaki Kurosu
 
Trinity Kings World Leadership: The Law of the Picture: *Leaders Are Examples...
Trinity Kings World Leadership: The Law of the Picture: *Leaders Are Examples...Trinity Kings World Leadership: The Law of the Picture: *Leaders Are Examples...
Trinity Kings World Leadership: The Law of the Picture: *Leaders Are Examples...Terrell Patillo
 
True definition of biblical leadership
True definition of biblical leadershipTrue definition of biblical leadership
True definition of biblical leadershipTerrell Patillo
 
Hope (Victoria Kirdiy)
Hope (Victoria Kirdiy)Hope (Victoria Kirdiy)
Hope (Victoria Kirdiy)Cachi Chien
 
121216 uxにもの申す
121216 uxにもの申す121216 uxにもの申す
121216 uxにもの申すMasaaki Kurosu
 
Little Wings (Hummingbird Hawk Moth)
Little Wings (Hummingbird Hawk Moth)Little Wings (Hummingbird Hawk Moth)
Little Wings (Hummingbird Hawk Moth)Cachi Chien
 
The King of the United States Kingdom
The King of the United States KingdomThe King of the United States Kingdom
The King of the United States KingdomTerrell Patillo
 
King Teola "Tee" Patillo II of the Patillo Family Kingdom goes to court to fi...
King Teola "Tee" Patillo II of the Patillo Family Kingdom goes to court to fi...King Teola "Tee" Patillo II of the Patillo Family Kingdom goes to court to fi...
King Teola "Tee" Patillo II of the Patillo Family Kingdom goes to court to fi...Terrell Patillo
 
Gherla Romania 2005 - Spring day in Europe project
Gherla Romania 2005 - Spring day in Europe project  Gherla Romania 2005 - Spring day in Europe project
Gherla Romania 2005 - Spring day in Europe project george papadopoulos
 
Trinity Kings World Leadership: Family Franchising Systems: Human Capital Man...
Trinity Kings World Leadership: Family Franchising Systems: Human Capital Man...Trinity Kings World Leadership: Family Franchising Systems: Human Capital Man...
Trinity Kings World Leadership: Family Franchising Systems: Human Capital Man...Terrell Patillo
 

Destaque (20)

Domain Driven Design with the F# type System -- F#unctional Londoners 2014
Domain Driven Design with the F# type System -- F#unctional Londoners 2014Domain Driven Design with the F# type System -- F#unctional Londoners 2014
Domain Driven Design with the F# type System -- F#unctional Londoners 2014
 
5 Best Practices For F# Development
5 Best Practices For F# Development5 Best Practices For F# Development
5 Best Practices For F# Development
 
Railway Oriented Programming
Railway Oriented ProgrammingRailway Oriented Programming
Railway Oriented Programming
 
Tata Communications Network Overview
Tata Communications Network OverviewTata Communications Network Overview
Tata Communications Network Overview
 
Trinity Kings World Leadership is the foundation for all Leadership, anything...
Trinity Kings World Leadership is the foundation for all Leadership, anything...Trinity Kings World Leadership is the foundation for all Leadership, anything...
Trinity Kings World Leadership is the foundation for all Leadership, anything...
 
Linked Open Data - A Means for Public Sector Information Management
Linked Open Data - A Means for Public Sector Information ManagementLinked Open Data - A Means for Public Sector Information Management
Linked Open Data - A Means for Public Sector Information Management
 
The Saints by Joe McFadden
The Saints by Joe McFaddenThe Saints by Joe McFadden
The Saints by Joe McFadden
 
Quick Look Video 01 29 11 Ws
Quick Look Video 01 29 11 WsQuick Look Video 01 29 11 Ws
Quick Look Video 01 29 11 Ws
 
Trinity Kings World Leadership: Family Franchising Systems: City of Dallas, TX
Trinity Kings World Leadership: Family Franchising Systems: City of Dallas, TXTrinity Kings World Leadership: Family Franchising Systems: City of Dallas, TX
Trinity Kings World Leadership: Family Franchising Systems: City of Dallas, TX
 
Estudo de ROI com LotusLive Para efeito de Demonstração
Estudo de ROI com LotusLive Para efeito de DemonstraçãoEstudo de ROI com LotusLive Para efeito de Demonstração
Estudo de ROI com LotusLive Para efeito de Demonstração
 
130315 HCD-Netにおける資格認定制度 (英文 certification system of hcd net)
130315 HCD-Netにおける資格認定制度 (英文 certification system of hcd net)130315 HCD-Netにおける資格認定制度 (英文 certification system of hcd net)
130315 HCD-Netにおける資格認定制度 (英文 certification system of hcd net)
 
Trinity Kings World Leadership: The Law of the Picture: *Leaders Are Examples...
Trinity Kings World Leadership: The Law of the Picture: *Leaders Are Examples...Trinity Kings World Leadership: The Law of the Picture: *Leaders Are Examples...
Trinity Kings World Leadership: The Law of the Picture: *Leaders Are Examples...
 
True definition of biblical leadership
True definition of biblical leadershipTrue definition of biblical leadership
True definition of biblical leadership
 
Hope (Victoria Kirdiy)
Hope (Victoria Kirdiy)Hope (Victoria Kirdiy)
Hope (Victoria Kirdiy)
 
121216 uxにもの申す
121216 uxにもの申す121216 uxにもの申す
121216 uxにもの申す
 
Little Wings (Hummingbird Hawk Moth)
Little Wings (Hummingbird Hawk Moth)Little Wings (Hummingbird Hawk Moth)
Little Wings (Hummingbird Hawk Moth)
 
The King of the United States Kingdom
The King of the United States KingdomThe King of the United States Kingdom
The King of the United States Kingdom
 
King Teola "Tee" Patillo II of the Patillo Family Kingdom goes to court to fi...
King Teola "Tee" Patillo II of the Patillo Family Kingdom goes to court to fi...King Teola "Tee" Patillo II of the Patillo Family Kingdom goes to court to fi...
King Teola "Tee" Patillo II of the Patillo Family Kingdom goes to court to fi...
 
Gherla Romania 2005 - Spring day in Europe project
Gherla Romania 2005 - Spring day in Europe project  Gherla Romania 2005 - Spring day in Europe project
Gherla Romania 2005 - Spring day in Europe project
 
Trinity Kings World Leadership: Family Franchising Systems: Human Capital Man...
Trinity Kings World Leadership: Family Franchising Systems: Human Capital Man...Trinity Kings World Leadership: Family Franchising Systems: Human Capital Man...
Trinity Kings World Leadership: Family Franchising Systems: Human Capital Man...
 

Semelhante a Dublin ALT.NET session Thu Oct 24 2013

Core .NET Framework 4.0 Enhancements
Core .NET Framework 4.0 EnhancementsCore .NET Framework 4.0 Enhancements
Core .NET Framework 4.0 EnhancementsRobert MacLean
 
Tdd with python unittest for embedded c
Tdd with python unittest for embedded cTdd with python unittest for embedded c
Tdd with python unittest for embedded cBenux Wei
 
Who killed object oriented design?
Who killed object oriented design?Who killed object oriented design?
Who killed object oriented design?Amir Barylko
 
Tdd is not about testing (OOP)
Tdd is not about testing (OOP)Tdd is not about testing (OOP)
Tdd is not about testing (OOP)Gianluca Padovani
 
Yevhen Tatarynov "From POC to High-Performance .NET applications"
Yevhen Tatarynov "From POC to High-Performance .NET applications"Yevhen Tatarynov "From POC to High-Performance .NET applications"
Yevhen Tatarynov "From POC to High-Performance .NET applications"LogeekNightUkraine
 
Testes? Mas isso não aumenta o tempo de projecto? Não quero...
Testes? Mas isso não aumenta o tempo de projecto? Não quero...Testes? Mas isso não aumenta o tempo de projecto? Não quero...
Testes? Mas isso não aumenta o tempo de projecto? Não quero...Comunidade NetPonto
 
Groovy Introduction - JAX Germany - 2008
Groovy Introduction - JAX Germany - 2008Groovy Introduction - JAX Germany - 2008
Groovy Introduction - JAX Germany - 2008Guillaume Laforge
 
Tdd is not about testing (C++ version)
Tdd is not about testing (C++ version)Tdd is not about testing (C++ version)
Tdd is not about testing (C++ version)Gianluca Padovani
 
Test driven development in .Net - 2010 + Eclipse
Test driven development in .Net - 2010 + EclipseTest driven development in .Net - 2010 + Eclipse
Test driven development in .Net - 2010 + EclipseUTC Fire & Security
 
White-box Unit Test Generation with Microsoft IntelliTest
White-box Unit Test Generation with Microsoft IntelliTestWhite-box Unit Test Generation with Microsoft IntelliTest
White-box Unit Test Generation with Microsoft IntelliTestDávid Honfi
 
Flink Batch Processing and Iterations
Flink Batch Processing and IterationsFlink Batch Processing and Iterations
Flink Batch Processing and IterationsSameer Wadkar
 
Online test program generator for RISC-V processors
Online test program generator for RISC-V processorsOnline test program generator for RISC-V processors
Online test program generator for RISC-V processorsRISC-V International
 
Jaap Groeneveld - Go Unit Testing Workshop
Jaap Groeneveld - Go Unit Testing WorkshopJaap Groeneveld - Go Unit Testing Workshop
Jaap Groeneveld - Go Unit Testing WorkshopJaapGroeneveld2
 

Semelhante a Dublin ALT.NET session Thu Oct 24 2013 (20)

Unit Testing with Foq
Unit Testing with FoqUnit Testing with Foq
Unit Testing with Foq
 
Core .NET Framework 4.0 Enhancements
Core .NET Framework 4.0 EnhancementsCore .NET Framework 4.0 Enhancements
Core .NET Framework 4.0 Enhancements
 
Agile mobile
Agile mobileAgile mobile
Agile mobile
 
Tdd with python unittest for embedded c
Tdd with python unittest for embedded cTdd with python unittest for embedded c
Tdd with python unittest for embedded c
 
Who killed object oriented design?
Who killed object oriented design?Who killed object oriented design?
Who killed object oriented design?
 
Tdd is not about testing (OOP)
Tdd is not about testing (OOP)Tdd is not about testing (OOP)
Tdd is not about testing (OOP)
 
Yevhen Tatarynov "From POC to High-Performance .NET applications"
Yevhen Tatarynov "From POC to High-Performance .NET applications"Yevhen Tatarynov "From POC to High-Performance .NET applications"
Yevhen Tatarynov "From POC to High-Performance .NET applications"
 
FSharp in the enterprise
FSharp in the enterpriseFSharp in the enterprise
FSharp in the enterprise
 
Testes? Mas isso não aumenta o tempo de projecto? Não quero...
Testes? Mas isso não aumenta o tempo de projecto? Não quero...Testes? Mas isso não aumenta o tempo de projecto? Não quero...
Testes? Mas isso não aumenta o tempo de projecto? Não quero...
 
Groovy Introduction - JAX Germany - 2008
Groovy Introduction - JAX Germany - 2008Groovy Introduction - JAX Germany - 2008
Groovy Introduction - JAX Germany - 2008
 
Unit testing - A&BP CC
Unit testing - A&BP CCUnit testing - A&BP CC
Unit testing - A&BP CC
 
Tdd is not about testing (C++ version)
Tdd is not about testing (C++ version)Tdd is not about testing (C++ version)
Tdd is not about testing (C++ version)
 
Test driven development in .Net - 2010 + Eclipse
Test driven development in .Net - 2010 + EclipseTest driven development in .Net - 2010 + Eclipse
Test driven development in .Net - 2010 + Eclipse
 
White-box Unit Test Generation with Microsoft IntelliTest
White-box Unit Test Generation with Microsoft IntelliTestWhite-box Unit Test Generation with Microsoft IntelliTest
White-box Unit Test Generation with Microsoft IntelliTest
 
Getting Started With Testing
Getting Started With TestingGetting Started With Testing
Getting Started With Testing
 
Review version 3
Review version 3Review version 3
Review version 3
 
Flink Batch Processing and Iterations
Flink Batch Processing and IterationsFlink Batch Processing and Iterations
Flink Batch Processing and Iterations
 
Online test program generator for RISC-V processors
Online test program generator for RISC-V processorsOnline test program generator for RISC-V processors
Online test program generator for RISC-V processors
 
Jaap Groeneveld - Go Unit Testing Workshop
Jaap Groeneveld - Go Unit Testing WorkshopJaap Groeneveld - Go Unit Testing Workshop
Jaap Groeneveld - Go Unit Testing Workshop
 
C#, What Is Next?
C#, What Is Next?C#, What Is Next?
C#, What Is Next?
 

Último

Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...apidays
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...apidays
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024The Digital Insurer
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Zilliz
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 

Último (20)

Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 

Dublin ALT.NET session Thu Oct 24 2013

  • 1. Testing . NET systems using F# HOW LONG WILL IT TAKE YOU? @RBARTELINK DUBLIN ALT.NET 24 OCTOBER, 2013
  • 2. The test pyramid  It’s not easy to achieve a good balance in a set of tests  Too much AT -> slow + doesn’t drive implementation properly  Too much UT -> Not meeting Living Documentation aim  One size won’t fit all http://martinfowler.com/bliki/TestPyramid.html (originated by Mike Cohn)
  • 4. Why?  You need to express high and low level tests  MbUnit, Sub/N/M/Spec are single paradigm  3 year old tests are uglier than 3yo production code  Test code is just different to production code  Learn a language a year  F# has been in VS since 2009  One of F#’s many paradigms is to be a better C#
  • 5. What can I use  Everything (yes, everything) you know  NUnit, MSpec, SpecFlow  FluentAssertions,  RhinoMocks, FakeItEasy, NSubstitute  Things you’re already using  xUnit.net, LINQ, Moq  Modern Libs  AutoFixture, AutoFixture.xUnit, AutoFixture.AutoMoq  Foq, AutoFixture.AutoFoq  TickSpec
  • 6. Gherkin  Feature files (Gherkin) Feature: Addition In order to avoid silly mistakes As a math idiot I want to be told the sum of two numbers Scenario: Add two numbers When I add 2 and 2 Then I should see 4
  • 7. TickSpec  TickFacts [<TickFact>] let AdditionFeature () = EmbeddedResourceFeatures.ScenariosFrom “Addition"  Step Definitions (TickSpec with unquote) module CalculatorSteps = [<When>] ``I add (.*) and (.*)`` x y = result <- Calculator() |> enter x |> plus |> enter y |> compute [<Then>] ``I should see (.*)`` expected = test <@ expected = result @>
  • 8. Gherkin Backgrounds and Outlines Feature: Addition Background: Given I switch my calculator to fancy mode Scenario Outline: The Hard Stuff When I add <First> and <Second> Then I should see <Total> Examples: |First|Second|Total| |1 |1 |2 | |9 |-1 |8 |
  • 9. Unit Testing  Tick methods (xUnit/NUnit with unquote) module CalculatorFacts = [<Fact>] let ``Adding two small ints works`` () = let result = Calculator() |> enter 2 |> plus |> enter 2 |> compute test <@ 2+2 = result @>  Mocking DSLs (Foq) Mock<IList<char>>.With(fun x -> <@ x.Count --> 2 x.Item(0) --> '0' x.Item(1) --> '1' x.Contains( any() ) --> true x.RemoveAt( 2) ==> System.ArgumentOutOfRangeException() @>)
  • 10. Low Level Stuff Type inference any() (for real) It.IsAny<DateTime>() mock() Mock.Of<T> Tuples let tuple = key,value let _,value = tuple var tuple = Tuple.Create( key, value) var value = tuple.Item2 Lambdas let gen a b = CreateSut a b |> Fill let gen = CreateSut >> Fill var gen = (int a, int b) => CreateSut( a, b).Fill() Object Expressions let time = { new ITime with member mock.GetHour() = 15} class FakeTime15 {int GetHour() { return 15;}} var time = new FakeTime15() Custom ops expected =? Actual // From unquote Asset.Equal( expected, actual) Quotations test <@ expected = result |> String.Concat “,” @> Assert.That( expected, Is.EqualTo( String.Concat( “,”, result))); let list = Mock<IList> .Method(fun x -> <@ x.Contains @>) .Returns( true) var mock = new Mock<IList>(); mock.Setup( x=> x .Contains( It.IsAny<object>()) .Returns( true)
  • 11. The bad points  Need to install FSC on CI server (2 clicks or 11 MB     MSI or put FSC in tools dir Just Works) You can’t mix F# and C# in a single project F12 from F# to/from C# doesn’t work (but built in Ctrl-, and F12 within files is fine) No refactoring support of consequence (but not as important as you think) C# starts to grate a little more every day (as does “in F# you can just…”)
  • 12. Books  Growing Object Oriented Software, Guided by Tests     (Freeman, Pryce) Specification By Example (Adzic) The RSpec book (Chelimsky et al) Expert F# 3 (Syme) Real World Functional Programming in F# and C# (Petricek, Skeet)
  • 13. Resources  F#  @ptrelford http://trelford.com/blog and samples  SO F# tag  Google  @tomaspetricek http://tomasp.net/blog/  Don’t forget MSDN  ATDD  GOOS  @ploeh Outside In Test Driven Development http://pluralsight.com/training/Courses/TableOfContents/ou tside-in-tdd