How to generate mock/testing data?

LAI TOCA
2 min readAug 8, 2019

--

Photo from https://saramorgan.net/2015/07/01/best-way-to-generate-lots-of-fake-test-data-for-force-com-orgs/

Generate sample data for unit, integration or even pressure test are usually as routine tasks for each engineer or data scientist. We could build those data manually from converting real data from existing database. Or we could choose library that did almost everything for us, the article introduce how to make time-consuming things more simple.

First, download and install Bogus:

NuGet Bogus
Bogus help create seeding within ease and intuition way.

Here are the sample how to generate mock/testing record(s) through Bogus.

Assume that we would like to make some member records for building contact list.

And the result as below:

Member records

That’s it. With fewer lines of code our sample data generated!😊

Reference

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

LAI TOCA
LAI TOCA

Written by LAI TOCA

Coding for fun. (Either you are running for food or running for being food.)

No responses yet

Write a response