If the SP is designed to change data, and if you do not allow the data to change, then how do you "check" the SP? You just make sure that he does not die? What if it does not return any errors, but does not insert data?
You can follow a similar path to what Valamas suggested, but you will also need to test the SP. For example, if specific data is intended to be inserted based on certain parameter values, you need to:
- Start transaction
- Create any test data in the database
- Call SP with specific parameter values
- Inside the transaction, check the database to see if the correct rows were inserted.
- Transaction rollback
I can't show you the code, but I managed to do it higher in the .NET code using the Visual Studio unit test framework. One could do the same with NUnit or any other unit test framework. I did not use the unit test database function for Visual Studio Database Projects. I just did the steps above in the code using ADO.NET and the SqlTransaction
class to control the transaction.
source share