Creating mock tests for persistent entities
In the recipe Creating integration tests for persistent entities, we saw how Spring Roo helps with the creation of integration tests. In this recipe we look at how Spring Roo simplifies the generation of a mock test for an entity using the test
mock
command.
Getting ready
Exit the Roo shell and delete the contents of the C:\roo-cookbook\ch02-recipes
directory.
Execute the ch02_jsr303_fields.roo
script. It creates a flight-app
Roo project and sets up Hibernate as the persistence provider using the persistence
setup
command. The script also creates a Flight
entity, which has FlightKey
as its composite primary key class, and adds fields to the Flight
and FlightKey
classes. If you are using a different database than MySQL or your connection settings are different from what is specified in the script, then modify the script accordingly.
Start the Roo shell from the C:\roo-cookbook\ch02-recipes
directory.
How to do it...
Follow these steps to create mock tests...