Monday, February 29, 2016

Using NBuilder for Unit Tests

When you are typically writing Unit Tests for your Visual Studio C# code, you will generally want to generate dummy/test data.  Well, you can hard code many of these values into your Unit Tests or you can use a tool such as NBuilder to do the job of generating all that test data for you!

If you are not familiar with NBuilder, it is available as a NuGet Library (which has not been updated in quite a while: https://www.nuget.org/packages/NBuilder/) as well as available for download from GitHub: https://github.com/garethdown44/nbuilder

If you take a look at the GitHub documentation, it may get you started, but may not be sufficient to answer all of your questions.

Fortunately, there is some additional documentation still sitting on the Google Code site that you can use as a secondary reference: https://code.google.com/archive/p/nbuilder/wikis/Overview_HowTo.wiki

Finally, this article covers some pretty good examples on how to work with NBuilder as well: http://www.jerriepelser.com/blog/creating-test-data-with-nbuilder-and-faker


No comments:

Post a Comment