Using FluentAssertions Library to Write Better Unit Tests in .NET C#


If you write unit tests, you must have known the basic Assert usages, such as Assert.IsTrue, Assert.AreEqual … It is less clear/clean than the fluent expressions. But first you would need to install the package FluentAssertions via the NuGet manager (right click the test project and click the Manage NuGet packages).

nuget-package-manager-fluentassertions Using FluentAssertions Library to Write Better Unit Tests in .NET C# c # unit tests

Install FluentAssertions at Nuget Package

Just Install it and the VS will add the required references automatically to your test project. Then you can start enjoy writing unit tests in the following [fluent] manner.

fluentassertion Using FluentAssertions Library to Write Better Unit Tests in .NET C# c # unit tests

fluentassertion example

fluentassertion-should Using FluentAssertions Library to Write Better Unit Tests in .NET C# c # unit tests

fluentassertion-should extensions

Isn't this cooler? It is much easier to understand each test statement because they are just as easy as plain English sentences. Click To Tweet

–EOF (The Ultimate Computing & Technology Blog) —

GD Star Rating
loading...
285 words
Last Post: How to Automatically Restart MySQL Server in the event of Crash?
Next Post: Bash Coding Exercise - HandShake

The Permanent URL is: Using FluentAssertions Library to Write Better Unit Tests in .NET C#

Leave a Reply