I am sure everyone knows the maintaining of test data is not a simple task because of all the issues surrounding test data. Over the years I have found the same issues consistently arise...
- What format should the test data be stored in?
- How to manage the transactional resetting of the test data between tests?
Well with a combination of a set of tools I have come up with what I feel is a solution solves these issues in a simple and "pretty slick" way.
I use DBUnit to manage the transactional resetting of the data between tests. DBUnit provides several formats to store the test data in which is great, however none of them are maintainable in the sense that if a record has to change you have to search through what could be a 5000 line text file for the record. You also have to maintain all FK relationships and constaints in this text file. Which often times results in having to running the tests to see if the test data is correct. To get around these issues I decided why not use what is a readily available tool to maintain FK relationships and constraints and that is MS Access.
What I do is change my dialect to the SQLServer dialect and regenerate a schema then I create a MS Access database with this sql and all of my look up values. Once I have my database I begin to enter in the test data and the value comes when Access tells I am violating a constraint or FK relationship. Then through JDBC I query the MS Access database and generate the DBUnit dataset.xml. If I ever need to change the data I simply modify my Access database and regenerate. So to my point...
One problem is SQLServer and MSAccess are not 100% compatible in terms of the sql they except (e.g. tinyint => yesno). So I ask has there ever been any discussion as to implementing a MSAccessDialect for purposes such as this?
If you would like more information as to my solution please feel free to ask.
Thanks
Tim