DEV Community


Using EasyRandom with Spring Framework

namuan profile image namuan Originally published at ・1 min read

Tired of creating objects in tests. Try using EasyRandom library. Here is how easily you can add it to a Spring Java project

Step 1: Add gradle/maven dependency

Step 2: Declare it in test

Step 3: Use it to generate random data objects

Step 4: 😍


Random initial seed

In the default setup, EasyRandom uses a default seed value to generate randam data.
Although it is quite simple to initiate EasyRandom with a random seed.

Enforcing javax.validation rules:

If an object is using javax.validation then there is an extension which enforces those rules when generating random objects.



Discussion (0)

Editor guide