Re: Best Way to Test Against a Database
- From: Michael Justin <michael.justin@xxxxxxx>
- Date: Tue, 13 May 2008 21:14:06 +0200
jehugaleahsa@xxxxxxxxx wrote:
I really don't care whether my SQL does what it's supposed to do, just
that I have my CommandText, CommandType and Parameters set up
correctly.
If your database client library (and the server) supports the concept of "prepared" statements, this would be a very easy way to verify the correctness of the SQL statements without actually executing the command. "Preparing" a statement will send the SQL to the server and the server can use the SQL to build a query plan. If the SQL is invalid, the server will complain (by raising an exception).
Usually I test all statements using a list (array) of SQL strings which will be iterated by the unit test. In a perfect test environment, every SQL would be wrapped in one test case. The test will then run over all SQL statements even if some of them fail.
This is my recommended reading for testing:
xUnit Test Patterns: Refactoring Test Code (Addison Wesley Signature Series) by Gerard Meszaros
Hope this helps(tm)
--
Michael Justin
SCJP, SCJA
betasoft - Software for Delphi™ and for the Java™ platform
http://www.mikejustin.com - http://www.betabeans.de
.
- Follow-Ups:
- Re: Best Way to Test Against a Database
- From: jehugaleahsa@xxxxxxxxx
- Re: Best Way to Test Against a Database
- References:
- Best Way to Test Against a Database
- From: jehugaleahsa@xxxxxxxxx
- Best Way to Test Against a Database
- Prev by Date: Re: Generic function to output the values of an Enumeration
- Next by Date: Re: How to fill a generics List with reflection?
- Previous by thread: Best Way to Test Against a Database
- Next by thread: Re: Best Way to Test Against a Database
- Index(es):
Relevant Pages
|