Populating test data using C# for realistic unit and integration testing
Is there any framework for .NET to populate test data? Yes here’s one I made earlier — Faker C# for generating fake data such as names, addresses, emails and the classic lorem ipsum placeholder text.
.NET Test-driven development Behavior-driven development
Faker C# is a port of the Ruby gem of the same name, which itself is a port of Perl’s Data::Faker library. It allows you to easily generate fake data: names, addresses, phone numbers, emails and lorem ipsum placeholder text.
Useful for populating seed data for local development and within unit tests. I’ve also used it to good effect within BDD-style tests when driving a web browser (e.g. Given a user account
creates a user with a Faker generated name, username and email address).
Getting started
Pull the code via git:
git clone git://github.com/slashdotdash/faker-cs.git
Or just grab the pre-built assembly Download »
Dependencies
- Requires the .NET framework 3.5 or later
Usage
-
Add a reference to
Faker.dll
in you project within Visual Studio. -
Start using the Faker methods to generate your random test data.
Names, phone numbers and emails
Addresses
Lorem Ipsum sentences and paragraphs
Buzzword bingo
Last, but not least, you can generate company names, catchphrases and bs!
Faker also supports i18n thanks to Patrick Drechsler who added the multi-lingual support and German translations.