Bootstrap using faker plugin

23 / Sep / 2012 by Vivek Sachdeva 0 comments

Every now and then we have to bootstrap data in our application. It takes lot of time thinking what name to give, what description to add and other stuff.
To overcome this, we can use faker plugin which can generate random tokens as per your need.

To use this, add following in BuildConfig.groovy

[java]
compile ":faker:0.6"
[/java]

And in BootStrap.groovy(or wherever we want to use it), just inject fakerservice:
[java]

def fakerService
[/java]

It gives us options to generate name, city, zip code, sentences with given word count, paragraphs with predefined sentence count and a lot more.

Some samples:

[java]

fakerService.name() — Santos Koelpin

fakerService.city() — West Domenic fort

fakerService.zipCode() — 60985

fakerService.sentence(10) — Et quod expedita in qui eligendi est error quos eos aperiam quia libero

[/java]

It saves a lot of time that we spend while bootstrapping data.

It helped me a lot.

Hope it helps you too.

Regards.

Vivek Sachdeva

vivek.sachdeva@intelligrape.com

Twitter : @vivek_sach

FOUND THIS USEFUL? SHARE IT

Leave a Reply

Your email address will not be published. Required fields are marked *