NFluent ( is an assertion library. Wait, there are making libraries even for asserting? Isn’t old good, built-in ‘Assert’ enough for everyone? NFluent has some nice features (expecting particular type of exception, collections and enums support), its fluent syntax is very pleasant to use, but there’s just one key feature that really kills all assertion libraries I’ve seen so far:

Failed assertions’ details printing

Once assertion fails, because (for instance) my variable a is not equal to 5, I’d really like to know what a was then. But I want to know it only when test fails, so I don’t want to do that by manual printing! So basically, until now, once my test has failed, I re-execute it with a breakpoint set at the failing assertion to do the manual inspection - it’s pretty much one redundant debugging cycle for every test I fix: what a waste! It’s pretty much unbelievable that no-one has addressed that earlier.

But NFluent really does it the good way and it does it for more complex cases as well: are you checking if an element was present in collection? If it wasn’t, you’ll know what was in there. Same applies for matching instances with types and all other assertion types NFluent recognizes.

It’s amazing to see how one little detail may be a really profitable game changer in some cases.

And if you want some of it in JS …

I’ve started to appreciate good asserting once I started to write tests in JavaScript - first, it was a real pain - until I’ve found a proper library to aid me with that. If you have the same problem, try Chai.js (, you’ll thank me later.

Share this post