The TestSetGenerator is an ant task for generating property files with testsets based on the results of SQL queries and validation plug-ins. Very usefull when building unit tests that make use of changing datasets. This task is an extension of the Ant SQL task.

To get a feeling how the TestSetGenerator works take a look at the following example:

  <target name="example1" description="One customer in San Francisco">

      description="TestSetGenerator Example"
      driver="${JDBC.DRIVER}" url="${JDBC.URL}" userid="${JDBC.USERNAME}" password="${JDBC.PASSWORD}" classpath="${JDBC.CLASSPATH}"

      <testset name="Customer in San Francisco" rowtoselect="first">
          select *
          from customer
          where CUST_CITY = 'San Francisco'
        <entry key="CUSTOMER.FIRST_NAME" column="CUST_FIRSTNAME"/>
        <entry key="CUSTOMER.LAST_NAME" column="CUST_LASTNAME"/>


In this example all customers from the customer table are selected which are living in San Francisco. Then from the first customer in the result set the first and the last name are added to the property file.

Take a look at the resulting property file :

# TestSetGenerator Example
# Generated by: Ant TestSetGenerator
# Generated on: 28-9-03 19:12
# URL: jdbc:hsqldb:../../database/ant_test_db
# Userid: sa

# Customer in San Francisco
# Row: First

Now you can let a JUnit test use this information to run a unit test against this customer.