Are there any tools or libraries that can be used to generate test data using JPA or entity beans? I believe this will be very helpful for unit testing where we can have an in memory database with data dynamically generated just when we start our testing. So, there will be no communication with actual DB servers and not any waste of time.
I was only able to find JPAMock. But it is still under development. It would be nice if someone could provide a good pointer.
Thanks a lot.
A test data generator is a specialized software tool that generates false or mock data for use in testing software applications. The generated data may be either random or specifically chosen to create a desired result.
SEQUENCE Generation. To use a sequence-based id, Hibernate provides the SequenceStyleGenerator class. This generator uses sequences if our database supports them. It switches to table generation if they aren't supported.
Annotation Type Id @Target(value={METHOD,FIELD}) @Retention(value=RUNTIME) public @interface Id. Specifies the primary key of an entity. The field or property to which the Id annotation is applied should be one of the following types: any Java primitive type; any primitive wrapper type; String ; java. util.
You could try out Random-JPA, a framework designed to generate random data. The setup is minimal.
I developed it and have been using it for over an year on our production tests. It works perfectly fine. Though it currently supports Oracle, MySQL & MSSQL with full feature.
Code: https://github.com/kuros/random-jpa
Tutorial: https://kuros.in/random-jpa
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With