Slide 1

Slide 1 text

AS YOU MEANT IT… 
 NFluent: the craft you needed 
 to boost your TDD
 Brown Bag Lunch - 2014 ! ! @tpierrain @cyrdup

Slide 2

Slide 2 text

WHO ARE WE? use case driven (blog) Many Cores (blog)

Slide 3

Slide 3 text

UNIT TESTS FROM THE TRENCHES…

Slide 4

Slide 4 text

COMMENTS?

Slide 5

Slide 5 text

IDEAL WORLD

Slide 6

Slide 6 text

HARD FACT #1 CONSEQUENCES error-prone
 reluctance to write tests
 relevance of tests? Tests assertions are needlessly difficult to write !

Slide 7

Slide 7 text

#1: WE DESERVE NO BRAINER ASSERTIONS!

Slide 8

Slide 8 text

HARD FACT #2 CONSEQUENCES tests are hard to maintain
 loss of trust in existing tests
 Removal of failing tests? Test intentions may be difficult to grasp

Slide 9

Slide 9 text

#2: TESTS INTENTIONS SHOULD BE OBVIOUS!

Slide 10

Slide 10 text

HARD FACT #3 CONSEQUENCES Need to debug the failing test to understand
 slowwww… TDD feedback loop
 Poor efficiency?!? When reliable… error messages are often unhelpful

Slide 11

Slide 11 text

#3:WE WANT TRUSTWORTHY & HELPFUL ERROR MESSAGES!

Slide 12

Slide 12 text

TDD IS NOT EASY… 
 
 … but NFluent will greatly help you

Slide 13

Slide 13 text

! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! (source: http://www.thefreedictionary.com/fluent) UBIQUITOUS LANGUAGE Fluent [ˈfluːənt] adj 1. spoken or written with ease: fluent French. 2. able to speak or write smoothly, easily, or readily: fluent in three languages. 3. smooth; easy; graceful: fluent motion 4. flowing or capable of flowing; fluid ! [from Latin: fluere to flow, stream]

Slide 14

Slide 14 text

#1: NO BRAINER ASSERTIONS! NFLUENT’S ANSWERS Natural language assertions A unique entry point for assertions (Check.That)
 
 IntelliSense guided writing (a.k.a. the super-duper-happy dot xp) Non ambiguous, contextualized and explicit error messages #2: OBVIOUS TESTS INTENTIONS! #3: TRUSTWORTHY & HELPFUL 
 ERROR MESSAGES!

Slide 15

Slide 15 text

COMBINING THOSE 3 WISHES, WE CAN REACH OUR IDEAL:
 EFFICIENT TDD!

Slide 16

Slide 16 text

! ! ! ! ! ! ! NFLUENT SAMPLES

Slide 17

Slide 17 text

DEMO

Slide 18

Slide 18 text

• NFluent is • An OSS .NET library for fluent assertions • Independent and compliant with all major .NET test runners • Directly inspired by the awesome Java FEST assert library • Available on IN A FEW WORDS

Slide 19

Slide 19 text

• A fully extensible model • No need to wait the NFluent team to add your own assertions on any kind of ‘value’ • The opportunity to use your own ubiquitous language (DSL) from within your tests ! • Some extra candies • Like the Properties extension method for IEnumerable • The HasFieldsWithSameValues(anonymous class) BONUS FEATURES

Slide 20

Slide 20 text

! ! 
 
 
 
 
 IN THE WILD tpierrain malat rhwy dupdob

Slide 21

Slide 21 text

! ! ! ! ! 
 Does your test framework dictate the way you work, or is it the other way around? FINAL QUESTION

Slide 22

Slide 22 text

APPLY TDD! Use NFluent!

Slide 23

Slide 23 text

APPLY TDD! Use NFluent! http://www.n-fluent.net

Slide 24

Slide 24 text

No content

Slide 25

Slide 25 text

APPENDIX

Slide 26

Slide 26 text

TDD: A WORKFLOW

Slide 27

Slide 27 text

(like: FluentAssertion, Sharp Tests Ex, etc.)
 • Their usage of lambda expression predicates hurts the fluent experience new[] { 1, 2, 3 }.Should().Contain(item => item > 3, "at least {0} item should be larger than 3", 1); • (Red is dead, but) Should is weak… • We aim to be more ambitious in term of fluentness NFLUENT VS. OTHER  ASSERTION LIBRARIES?

Slide 28

Slide 28 text

• For NFluent contributors • No warning (all warn as ERROR) • No StyleCop warning (full rules) • 100% of test coverage - all test passed of course! • The entire build lasts less than a minute (including all unit tests) DEFINITION OF DONE

Slide 29

Slide 29 text

! ! ! ! ! ! ! BY TEST DEVELOPMENT DRIVEN IS?

Slide 30

Slide 30 text


 Use NFluent! ! ! ! ! WRITE VALUABLE TESTS (NFluent logo © rhwy) ! http://www.n-fluent.net Thank you!