• Home
  • RSS Feed
  • Log in

Automatic test data generation
Posted by Erik Jan de Wit in the late afternoon: February 28th, 2008

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.

  • Share/Bookmark

Filed under AOP, Frameworks, Java, Spring, Testing | 2 Comments »



2 Responses to “Automatic test data generation”



    Ron Thijssen Says:
    Posted at: February 29, 2008 at 9:16 am

    This looks like a really interesting framework. Respect for sharing this little framework with us! I’m going to give it a try this weekend. Although, I still have some doubts about the feasibility.

    Cheers, Ron



    Erik Jan de Wit Says:
    Posted at: February 29, 2008 at 10:18 am

    Be sure to check out the example web application, default it works with the framework without configuration but when you add -Dbeesting.beangenerator.config.file=jag-example-generators.xml

    Then you can see the full potential of it.



Leave a Reply

Click here to cancel reply.

Deployment automation for Java application running on Websphere, WebLogic and JBoss

Archives

  • March 2010
  • February 2010
  • January 2010
  • December 2009
  • November 2009
  • October 2009
  • September 2009
  • August 2009
  • July 2009
  • June 2009
  • May 2009
  • April 2009

Xebia Sites

  • Xebia Corporate
  • Xebia France
  • Xebia India

Categories

  • Java (282)
  • Agile (109)
  • General (50)
  • Testing (42)
  • Performance (42)
  • Hibernate (36)
  • Scrum (33)
  • Podcast (31)
  • Architecture (31)
  • Spring (28)
  • SOA (24)
  • Maven (22)
  • Project Management (22)
  • Middleware (23)
    • Deployment (14)
  • Flex (17)
  • JPA (17)
  • Eclipse (15)
  • Xebia Labs (15)
  • Quality Assurance (14)

Tag Cloud

    fitnesse Agile Awareness Workshop IntelliJ qcon Ajax Performance Xebia Poppendieck Architecture Hibernate Closures Introduction to Agile Testing Grails Lean XML esb SOA Maven Seam Groovy product owner JavaOne Java Spring Agile Semantic Web Scrum Scala Functional Programming