Skip to content

DatabaseProcessing

jochenwierum edited this page Jul 28, 2012 · 1 revision

Processing database queries

Querying a database results in java.sql.ResultSets. These ResultSets are complex iterators which can not be used in RowFixtures. However, FitGoodies makes use of the ByteCode Engineering Library to transform these ResultSets into an object array which can be handled by Fit.

The de.cologneintelligence.fitgoodies.database.ResultSetFixture has one method, which should be called from setUp(): setResultSet. You can use the fixture like any other RowFixture.

If you only want to check the content of a database table, FitGoodies can request the data for you. As always, this happens using a SetupFixture:

fitgoodies.database.SetupFixture
provider org.apache.derby.jdbc.EmbeddedDriver
connectionString jdbc:derby:data/db;create=true

(there are two more optional rows: user and password)

To check the content of the table STORE, we can simply type:

fitgoodies.database.TableFixture table=STORE
ISBN AUTHOR TITLE PRICE
1930110995 Vincent Massol, Ted Husted JUnit in Action 26.37
193239480X Steve Loughran, Erik Hatcher Ant in Action 31.49

This is great for regression tests: You can simply copy the table content into your HTML file and format it as a HTML table.

Clone this wiki locally