Automatic test data generation
We’ve all being there, we’ve all had this on a project once or maybe even more times. The assignment is to build an application but there is no data for you to work with. There could be any number of reasons this could be the case - to name a few, the web-service that should be connected is not done in time, the database migration is postponed. Then someone has to create database scripts with test data, or implement a test web-services. This is all a waste of time.
But lucky for you now there is a solution.
I've created an little framework that is easy to setup and will create test data automatically. So how does it work, simple, its entry point is a method interceptor that you can wrap around anything you want, there doesn't even have to be an implementation. So that DAO you want to use, but the database is still empty, just let our framework step into place and all the methods return the data that you want.
It is set up in a way that you don't need to configure a lot to get data, otherwise it will defeat it's purpose. The framework consists of generators. These generators can generate data for specific classes - for instance there is a FloatingPointGenerator that will generate floating point numbers randomly. The framework will try to figure out what kind of objects need to be returned, instantiate these objects and than generate data for all its properties.
Sometimes randomly created Strings or Numbers just won't work because it must be valid data. That's why you can override the defaults. For a specific field you can use an alternative generator. If for instance your domain model object has a postal code property you can set it up to use a the RegularExpressionInstanceGenerator. This generator can be used to generate Strings that match the regular expression that it was configured with.
If this article has raised your curiosity take a look at the sourceforge site for more information.