Generating Fake Data in C# with Bogus

preview_player
Показать описание
Having data to test with is important. Whether you want to create unit tests that better replicate the real world or you want to insert sample data in the database, the key is to have representative data without spending a lot of time generating it.

That's where the Bogus library comes in. This open-source NuGet package allows us to quickly generate fake data that can be used for any number of purposes in our application or our database. In this video, we are going to look at how to quickly spin up an application that makes use of fake data that is generated by Bogus.

Рекомендации по теме
Комментарии
Автор

Thank you Tim! Our team is learning Unit Tests right now and you have one about Bogus. Thank you for your work for community! 😊

dtntracer
Автор

This is the second time you upload a problem solving video after I discuss with my colleague about it. Yesterday we were discussing how should we seed the database every time we run a new instance in docker.
Very useful video, Thanks Tim!

YazanGplay
Автор

Started a new project and this was the testing suit selected. Life saver...

troybryantIII
Автор

Great video and finally something what isn't two hours long ;) Thx Mr.Corey

jakubduch
Автор

As always great demos and instruction. Perfectly timed as I am creating large sets of data for a product demo.

steveclarke
Автор

Thank you Tim for all your and your team work. I have learned tons from your courses library (each course is a masterpiece on it's own), as well as from YT. Cannot wait for new things :)
PS. Bogus is a Polish name :))

lukaszrutkowski
Автор

Great find and demonstration of this library! Thanks for sharing!

EluviumMC
Автор

Did you know that bogus had a dumpstring method. If you used the DumpString method, it would return the json. Then a normal class for the model would be fine.

andywalter
Автор

Thanks Tim! This seems to be an excellent tool to test database performance degradation too!

claudiocespon
Автор

Amazing as always Tim! Thanks so much!

tresaidhy
Автор

I like it a lot, but for other countries than the US you may need to create extensions, f.i. to generate valid phone numbers, addresses, and ZIP codes. For example, the Dutch ZIP code is structured like this: four digits, a space and the two characters like 2231 ZZ. I have seen you can do that. I will give it a try.

HollandHiking
Автор

Thank you Tim. I started to implement random generator by myself. I should probably google for existing solutions at first :)

dmytrohryhsyn
Автор

having worked with many frameworks across languages, I do see the appeal of a heavy battery-included framework. The industry nowadays tend toward micro-framework that start out small and open for plugin or addon to expand functionality, and we add things as we need it. Which make sense in its own right

But for heavy frameworks, everything is streamlined and function with each other much more coherent.

Laravel, for example, had almost every layer of a typical application built into its core. The DataGenerator, which they called DatabaseFactory, and the Seeder itself where you define the rule for each model, using the popular FakerPHP that they also maintain; are all configured in the fresh installation of the framework. Which, also heavily documented.

Also, things like data-aware input validation. Even something that could be as simple as "username must be unique" can be quite a hassle in Python Flask or Java Spring Boot, or even Asp.net, since the data access isnt really a part of the framework. Though it do open for us the freedom to choose our Orm. I really miss

'username' => [
'required',
'unique:users, email_address',
'max:20',
'min:10'
],

khangle
Автор

Great tool for testing the application.
Thank you

MrMAbukhadra
Автор

Bogus is extremely helpful, thanks for the video!

KorruFreez
Автор

Always use this for unit testing it ensures you don't have know values in your test for values that don't need to be fixed forcing the dev to think about the logic not the data.

killpopers
Автор

This is awesome! I can see a lot of use cases!

CodeLlama
Автор

Wow, I was just checking fake data libraries for a work project today!

hadrien
Автор

Hi, how is it possible to give sequential Id instead of random?

microtech
Автор

Is there a way to generate data specific for a country? Zip codes have different formats. Maybe use names of people and streets and cities that can occur in a country?

Mnedula