I am develeping a solution to achieved database test driven develepment for testing stored procedure changes. My thoughts so far is to execute the stored proc and store the expected data and schema results set in a raw format. Make the sp change then execute the stored proc again and assert that the schema and data are equal.
At 1st I stored the data in a sql server database like:-
testdata.storedproc
- ID – int
- ResultsSet – int
- Data – XML
- Date – DateTime
testschema.storedproc
- ID – int.
- ResultsSet – int.
- Schema – XML.
- Date – DateTime.
All was going well until i found a stored proc that has is causing me headache:-
The stored procedure :-
- has multiple results sets.
- has columns that contains the same column name ie. (person.name, area.name).
- has data contains with illegal xml characters.
- has results in excess of 120000 rows.
This breaks my intital soultion, does anyone have any knowlege on database test driven development that they would like to share, or have alternative solutions that could be of use?
I have had a great deal of success using the DbFit library (in conjunction with Fit/Fitnesse) to develop stored procedures in a test-first manner. Tests are written in HTML, either as standalone files (Fit) or Wiki pages (FitNesse). DbFit manages the database connectivity, executes queries and stored procedures, and (by default) wraps each individual test in a transaction to help keep things repeatable.
For more on Fit/Fitnesse, see the FitNesse site and the questions tagged fitnesse here on StackOverflow. DbFit can be found on GitHub.