Project Description
Fluent Tests is a project for writing unit tests in a fluent way.

Why a new framework and why FluentTests ? :

  • Framework independent. You write your tests the same way either you are using NUnit or MSTest. Adding support for yet another framework is an easy task.
  • The test are written in fluent english that is much easier to read, i.e. Ensure.That(actual).Is.GreaterThan(5)
  • Extendable. You can add test methods that you are missing yourself by simply writing new extension-methods.


The usual Assert-methodology can sometimes be a little bit hard to read and it is all to often very confusing regarding the parameters. To make the testing more fluently the Fluent Tests project offers a new kind of language for testing.

The test are now written as Ensure.That instead of plain old Assert. For example,

  • Assert that a value is greater than 3.
     
    Assert.IsTrue(actual>3) => Ensure.That(actual).Is.GreaterThan(3)
  • Assert that a collection has element

    Assert.IsTrue(list.Items.Count>3) => Ensure.That(list).Is.Not.Empty()

Also, the Fluent Tests project support multiple testing frameworks, currently NUnit and MSTest. So, if you prefer a certain framework you can mix the Ensure-syntax with the old Assert syntax.

Why not use NUnit-fluent as is? Well, the NUnit-fluent syntax can be thought of as bit less readable but it's really just a matter of taste. In NUnit you would type Assert.That(list,Is.Not.Empty). Put together the difference is minimal :

Assert.That(list,Is.Not.Empty);
Ensure.That(list).Is.Not.Empty()

But, one big difference is that you don't have to make a final decision regarding the choice of testing framework, you may change framework at any time. Also, you may extend the framework by adding your own tests. This is done simply by writing an extension-method.

Available with Nuget

NugetFluent Tests is now available with Nuget. 
Simply choose "Add Library Reference" on your project, locate the project and choose install. Now you're ready to go! 

 

 

Read the blog

There is a blog, tidycode.wordpress.com, where this framework is discussed, be sure to visit it for even more information regarding the framework.

Last edited Jun 22, 2011 at 3:15 PM by Arvander, version 14