I do not know which tool can perform unit test for SQL statements or storage procedures. I usually write a SQL script to do a test for this.
- Create an empty database, of course, the same structure as the original one.
- Prepare the data (import some data from the source database).
- Call the stored procedure.
- Then look at the data if it is true or not.
Sometimes they write some statements, such as
IF EXISTS (SELECT * FROM XX INNER JOIN XXX ON XXXXXXXX WHERE XXX=XXX) RAISEERROR XXXXXX
If you encounter some exceptions or errors, you can check the stored procedure.
But this is a waste of time.
Usually I check the entire execution path of the stored procedure most of the time and just check the main pending error points.
Tim li
source share