Click here to Skip to main content
15,881,380 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
Hi,

I am working on a Project that involves testing a Simple SQL Query like, SELECT, INSERT, UPDATE AND DELETE.

The VS 2010/ 2012 is the test environment. I know how to test a SP using MS unit Testing framework. But as per the requirement I need to test the above said SQL Commands / Queries as well without wrapping these statements in a SP.

Please help me.

Thanks,
Raghuveer

What I have tried:

Tried testing the SP using VS 2010
Posted
Updated 4-Apr-16 9:43am
Comments
Tomas Takac 4-Apr-16 6:37am    
Why do you need to test those simple queries? I'm just wondering what such a test is good for. In tests you usually focus on a piece of logic. What are you going to test here?
RickZeeland 4-Apr-16 6:55am    
I don't see the problem, just wrap your queries in C# methods that return Boolean and then use these methods in your Unit testing. I use Nunit btw. but I don't think this makes much of a difference.
Sinisa Hajnal 4-Apr-16 8:01am    
You test simple queries just as you test stored procedures. The only difference is that your queries are type text instead stored procedure.

1 solution

You might try TSQLT - THE DATABASE UNIT TESTING FRAMEWORK FOR SQL SERVER, which allows you to implement unit tests in T-SQL.
It is open source and you can find it here: tSQLt - Database Unit Testing for SQL Server[^]
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900