IntroductionThe 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">
<testsetgenerator
description="TestSetGenerator Example"
driver="${JDBC.DRIVER}" url="${JDBC.URL}" userid="${JDBC.USERNAME}" password="${JDBC.PASSWORD}" classpath="${JDBC.CLASSPATH}"
file="example1.properties">
<testset name="Customer in San Francisco" rowtoselect="first">
<query>
select *
from customer
where CUST_CITY = 'San Francisco'
</query>
<entry key="CUSTOMER.FIRST_NAME" column="CUST_FIRSTNAME"/>
<entry key="CUSTOMER.LAST_NAME" column="CUST_LASTNAME"/>
</testset>
</testsetgenerator>
</target>
In this example all customers from the
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
CUSTOMER.FIRST_NAME = Michael
CUSTOMER.LAST_NAME = Clancy
Now you can let a JUnit test use this information to run a unit test against this customer. |