SQLUnit TUI Tool

This tool was originally contributed by Sahib S Wadhwa for use with Oracle databases and subsequently modified by Sujit Pal to make it more database agnostic.

The TUI tool is a console based tool for manufacturing test cases by running the stored procedure against the database. The tool will generate the XML for the test case, which can then be cut and pasted into the test specifications. The tool eliminates the drudgery of having to write the XML test cases by hand, speeding up the test building process enormously. It also has a new interactive interface similar to text based database client tools. The inputs can be either partially or fully driven by the contents of a Java properties file, thereby making it partially or completely non-interactive if desired.

Here is a sample run of the TUITool. Make sure that the JDBC Driver for the database you are using, the JDOM JAR file and the SQLUnit JAR file is in your CLASSPATH. Alternatively, set the CLASSPATH on the java command line with -cp.


$ ant tui [-Dtui.mode=offline] [-Dtui.rcfile=etc/tuirc.properties]

SQLUnit TUI Tool
Copyright(c) 2003 The SQLUnit Team
TUITool:_captureFile> /home/sujit/sqlunit/tui.out
TUITool:_connection!driver> com.mysql.jdbc.Driver
TUITool:_connection!url> jdbc:mysql://localhost:3306/sqlunitdb
TUITool:_connection!user> defaultuser
TUITool:_connection!password> defaultuser
TUITool:__test!name> Checking returned value from customer
TUITool:__test!call!stmt> select custId from customer where custId=?
TUITool:___test!call!param[1]!type> INTEGER
TUITool:___test!call!param[1]!inout> in
TUITool:___test!call!param[1]!is-null> false
TUITool:___test!call!param[1]!value> 1
<test name="Checking returned value from customer">
  <sql>
    <stmt>select custId from customer where custId=?</stmt>
    <param id="1" type="INTEGER" inout="in" is-null="false">1</param>
  </sql>
  <result>
    <resultset id="1">
      <row id="1">
        <col id="1" type="INTEGER">1</col>
      </row>
    </resultset>
  </result>
</test>

Output captured to /home/sujit/sqlunit/tui.out
TUITool:__test!name> q
$ 

The -Dmode=offline indicates that all replies to the prompts are stored in the supplied properties file indicated by -Drcfile. Offline mode can be used to run only a single test and is totally non-interactive. When the interactive mode is desired, some things such as the connection information, can be stored in the properties file to minimize typing effort.

The properties file is a standard Java properties file. A sample properties file is included in the distribution in etc/tuirc.properties. This will need to be modified and copied to whatever you want to call your rcfile for the SQLUnitTUI Tool. The keys mimic the prompts that the tool provides.