mini-training: nfluent

17
Nfluent

Upload: betclic-everest-group-tech-team

Post on 10-May-2015

604 views

Category:

Technology


0 download

DESCRIPTION

NFluent is an ergonomic check library which aims at improving the flow of your .NET TDD experience

TRANSCRIPT

Page 1: Mini-Training: NFluent

Nfluent

Page 2: Mini-Training: NFluent

• Definitions

• Why use Nfluent

• Create your own check method

• Nfluent Definition of Done (DoD)

Agenda

Page 3: Mini-Training: NFluent

• NFluent is an ergonomic check library which aims to fluent your .NET TDD experience (based on simple Check.That() assertion statements)

• An important part of the NFluent value is to allow a smooth writing of all the checks.

• NFluent by it’s nature, provides a really nice way to produce tests that make sense

• NFluent is not coupled to any .NET unit test framework. It is fully designed to work in collaboration with your favorite one

• NFluent is directly, but also freely, inspired by the Java FEST fluent check/reflection library (http://fest.easytesting.org/).

• It’s a simple nuget package

PM> Install-Package NFluent

What is Nfluent?

Page 4: Mini-Training: NFluent

4

Why useNfluent?

Simply because it makes your TDD more fluent

Page 5: Mini-Training: NFluent

5

NFluent aims your tests to be fluent to writeauto-completion:

With a super auto-completion 'dot' experience. Indeed, just type the Check.That() followed by one of your object and a dot, and your IDE will show you all the checks available for the type of the given object to verify. No more, no less ( no auto completion flooding)

with Nfluent: with assert method:

No hesitation about the kind of check that is possible and available regarding my current System Under Test (SUT)

All you've got to remember is: Check.That, cause every check is then provided via auto-completion

Page 6: Mini-Training: NFluent

6

Fluent to read

• very close to plain English, making it easier for non-technical people to read test code

• your tests should also be your documentation and providing fluently sentences near plain english instead of questionable asserts will enhance that

• Other check libraries have not chosen the proper vocabulary (they use Should() instead of Must())

With nfluent you'd rather rely on a stronger semantic for your checks

( NFluent's Check.That)

Page 7: Mini-Training: NFluent

7

fluent to troubleshoot

• every failing check of the NFluent library throws an Exception with a crystal-clear message status to ease your TDD experience

• no need to set a breakpoint and to debug in order to be able to figure out what went wrong.

Page 8: Mini-Training: NFluent

8

less error-prone

• no more confusion about the order of the "expected" and "actual" values you can find in the classical .NET unit tests frameworks

With assert method confusion with expected and actual

With Nfluent all is clear, just check.that:

• all unit tests error message are reliable when tests are failing

Page 9: Mini-Training: NFluent

9

helpful to reverse engineer legacy code

• temporarily write an on-purpose failing assert on a legacy method, so you can understand it and leverage on the "ready-to-be-copied-and-paste-for-arrays-or-collections-initialization-purpose" NFluent assert failure messages

• With check error message also well formated so that we can easily instanciate arrays and collections type initializers

Page 10: Mini-Training: NFluent

10

Red Green Refactor

Page 11: Mini-Training: NFluent

11

Create your own check method• All the secret of the NFluent extensions is on the ICheck<T> returned by the

Check.That<T>(T sut)

• The idea is to provide an extension method on the ICheck<T> interface for the T type you want to check.

With existing tests

A new test

Page 12: Mini-Training: NFluent

12

Demo

Page 13: Mini-Training: NFluent

• No warning during the build (warn as error)

• No StyleCop warning

• 100% of test coverage for the NFluent project

– Test names should be clear enough to know what is in stakes here

• The entire build (i.e. including all the unit tests execution) takes less than a minute

• With (of course) all unit tests passed ;-)

13

Nfluent Definition of Done (DoD)

Page 14: Mini-Training: NFluent

• https://github.com/tpierrain/NFluent

• http://www.codedistillers.com/rui/2013/11/26/nfluent-extensions/

• http://www.nuget.org/packages/NFluent/

14

Page 15: Mini-Training: NFluent
Page 16: Mini-Training: NFluent

Find out more

• On https://techblog.betclicgroup.com/

Page 17: Mini-Training: NFluent

About Betclic• Betclic Everest Group, one of the world leaders in online gaming, has a unique

portfolio comprising various complementary international brands: Betclic, Everest Gaming, bet-at-home.com, Expekt…

• Active in 100 countries with more than 12 million customers worldwide, the Group is committed to promoting secure and responsible gaming and is a member of several international professional associations including the EGBA (European Gaming and Betting Association) and the ESSA (European Sports Security Association).

• Through our brands, Betclic Everest Group places expertise, technological know-how and security at the heart of our strategy to deliver an on-line gaming offer attuned to the passion of our players.