Good Fake Data

When it comes to testing your code, good data is hard to come by. For new greenfield solutions, there often is no data. And using production data is a bad idea for a variety of reasons.

But that doesn’t reduce the importance of good test data. We need good test data, and good (read: realistic) data is essential when building out rich applications.

That is where Bogus comes in. If you’ve never heard of it, Bogus is a data generator that quickly and easily produces fake data and seed databases for many of your testing needs. Bogus doesn’t just support names / addresses, it can do phone numbers, email address, and many more.

Here’s how to get started with Bogus.

Create a new .NET Core 2.0 console application.

Good Fake Data

Install the NuGet package for Bogus.

Bogus

Interacting with Bogus is easy. To create a new name, just use the names dataset.

To create a new address, use the address dataset.

Now putting it all together we can generate 10,000 addresses.

Having good fake data is important for when testing most applications. Tools such as Bogus should be part of every developer’s toolbox. They reduce friction for that part of development that can get tedious.

Work smarter, not harder.

Try it out and let me know what you think.

author avatar
Chad Michel Senior Software Architect
Chad is a lifelong Nebraskan. He grew up in rural Nebraska and now lives in Lincoln. Chad and his wife have a son and daughter.

Related posts