NFluent

Boost your .NET TDD experience!

NFluent is on Nuget!

Introducing NFluent.

NFluent speeds up and eases the way you write your assertions

View details »

NFluent accelerates your test troubleshooting sessions

View details »

NFluent error messages are not only useful, but reliable by nature

View details »

NFluent transforms your tests into readable documentation

View details »

NFluent allows you to easily add the verbs you need for your tests

See here how »

And of course, you can keep working with your favorite test runner!

View details »

Actually, we aim to release the most fluent .NET assertion lib ever ;-)

See here why »





NFluent speeds up and eases the way you write your assertions

(that we call 'checks' BTW, to avoid conflicts with all your favorite test runners)

Check.That() is all you've got to remember! before you get carried away by the super-duper-happy-DOT experience of NFluent (i.e. the IntelliSense experience)


With NFluent, you can write simple checks like this:
var integers = new int[] { 1, 2, 3, 4, 5, 666 };
Check.That(integers).Contains(3, 5, 666);

integers = new int[] { 1, 2, 3 };
Check.That(integers).IsOnlyMadeOf(3, 2, 1);

var guitarHeroes = new[] { "Hendrix", "Paco de Lucia", "Django Reinhardt", "Baden Powell" };
Check.That(guitarHeroes).ContainsExactly("Hendrix", "Paco de Lucia", "Django Reinhardt", "Baden Powell");

var camus = new Person() { Name = "Camus" };
var sartre = new Person() { Name = "Sartre" };
Check.That(camus).IsNotEqualTo(sartre).And.IsInstanceOf<Person>();

var heroes = "Batman and Robin";
Check.That(heroes).Not.Contains("Joker").And.StartsWith("Bat").And.Contains("Robin");

int? one = 1;
Check.That(one).HasAValue().Which.IsPositive().And.IsEqualTo(1);

const Nationality FrenchNationality = Nationality.French;
Check.ThatEnum(FrenchNationality).IsNotEqualTo(Nationality.Korean);

string motivationalSaying = "Failure is mother of success.";
Check.That(motivationalSaying).IsNotInstanceOf<int>();
        
With NFluent, you can also write checks like this:
var persons = new List<Person>
                     {
                         new Person { Name = "Thomas", Age = 38 },
                         new Person { Name = "Achille", Age = 10, Nationality = Nationality.French },
                         new Person { Name = "Anton", Age = 7, Nationality = Nationality.French },
                         new Person { Name = "Arjun", Age = 7, Nationality = Nationality.Indian }
                     };

Check.That(persons.Extracting("Name")).ContainsExactly("Thomas", "Achille", "Anton", "Arjun");
Check.That(persons.Extracting("Age")).ContainsExactly(38, 10, 7, 7);
Check.That(persons.Extracting("Nationality")).ContainsExactly(Nationality.Unknown, Nationality.French, Nationality.French, Nationality.Indian);

// more fluent than the following classical NUnit way, isn't it? 
// CollectionAssert.AreEquivalent(persons.Extracting("Age"), new[] { 38, 10, 7, 7 });

// it's maybe even more fluent than the java versions

// FEST fluent assert v 2.x:
// assertThat(extractProperty("name" , String.class).from(inn.getItems())).containsExactly("+5 Dexterity Vest", "Aged Brie", "Elixir of the Mongoose", "Sulfuras, Hand of Ragnaros", "Backstage passes to a TAFKAL80ETC concert", "Conjured Mana Cake");

// FEST fluent assert v 1.x:
// assertThat(inn.getItems()).onProperty("name").containsExactly("+5 Dexterity Vest", "Aged Brie", "Elixir of the Mongoose", "Sulfuras, Hand of Ragnaros", "Backstage passes to a TAFKAL80ETC concert", "Conjured Mana Cake");
        
Or like this:
// Works also with lambda for exception checking
Check.ThatCode(() => { throw new InvalidOperationException(); }).Throws<InvalidOperationException>();

// or execution duration checking
Check.ThatCode(() => Thread.Sleep(30)).LastsLessThan(60, TimeUnit.Milliseconds);
        


< Back



NFluent accelerates your test troubleshooting sessions

With truly-helpful error messages provided, NFluent spares you a few sessions with the debugger in your day to day work

Another booster for your productivity, and to reduce your TDD feedback loop ;-)


Samples of crystal-clear error messages












< Back



NFluent error messages are not only useful, but reliable by nature

Indeed, NFluent is less error-prone for your day to day work.

It ends the issue related to wrongly ordered "expected" and "actual" values

That you can find within the classical .NET unit tests frameworks assertions.

Here, the distinction between the expected value and the one to be checked is natively enforced by the NFluent syntax. Thus, no question to ask ourselves when we write our assertions. And no question to ask ourselves when consulting the error messages on our Software Factory dashboard.


< Back



NFluent transforms your tests into readable documentation for your peers

Very close to plain English, the NFluent syntax makes your tests easier to read even for non-developers people (QA, BA)


< Back



NFluent is fully extensible to your specific needs


You want to add new verbs for your checks, and create your DSL for testing your own business objects? Can't be easier with our mechanism based on .NET extension methods, and the helpers we provide to ease this job.

You wanna try? Follow the white rabbit here, or read the nice article published by Rui on CodeDistillers' blog.


< Back



And of course, you can keep working with your favorite test runner!

NUnit    xUnit    specflow     . . .

Indeed, NFluent is simply an awesome assertion library, and ... she's not exclusive ;-)


< Back


That's right: we aim to release the most fluent .NET assertion lib ever ;-)

There were attempts made previously by other open source projects, but even the most serious alternative did not suit our needs.

Indeed:


Is the next statement fluent to write for you?!?
var myArray = new[] { 1, 2, 3 };

myArray.Should().Contain(item => item > 3, "at least {0} item should be larger than 3", 1);

We don't think so, and we prefer the NFluent version:
Check.That(myArray).IsGreaterThan(3);


Other example: are you happy to type new[] {...} as a method argument like does another famous "fluent" library?

myArray.Should().Have.SameSequenceAs(new[] { 1, 2, 3 });

or like us, you prefer to type:
Check.That(myArray).ContainsExactly(1,2,3);

NFluent is different

Because fluentness is our grail

It's an obsession for us, and everything we do (API, error messages, ...) is completely driven by this research.
NFluent is really awesome pal. Try it, you will see!


Wanna go to the next level with us?

You should follow what's gonna be delivered soon by the NFluent team... Cause based on Rui's reflexions, we decided to develop a NFluent plugin (whether a Visual Studio or R#).

This upcoming NFluent plugin should definitely revolutionize the way we TDD!



Of course, you can also contribute to the NFluent initiative via pull request, or via the NFluent newsgroup for any comment, remark or question on the library.


< Back to the top


Wall of fame

Many thanks:


Thomas PIERRAIN, creator of NFluent


< Back to the top