Laurent Hinoul

“Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.” - John F. Woods

How to add dummy data to your java object

When you are unit testing, it is sometimes necessary to supplement an object with dummy data. Unfortunately, to fill a large object manually, it crawls a lot of time and work. Fortunately, there is a tool that saves us the time and work!

At https://code.google.com/p/dummycreator/wiki/DummyCreator, you can find a java library that fills an object with dummy data by typing one line of code.

If you use Maven, you can add the following dependency:

Example

In this example, we want to add dummy data for an object User.

Now, to fill this object, type the following code:

It’s easy as that! Enjoy! 😀

Leave a Reply

%d bloggers like this: