Re: Best Way to Test Against a Database



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
.



Relevant Pages

  • Re: Best Way to Test Against a Database
    ... that I have my CommandText, ... "Preparing" a statement will send the SQL to the server and the ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Master/Detail with ADODatasets (again)
    ... So that means the SQL statements use to retrieve data from the ... I just set the CommandText in Patients to 'Select ... then save it back to the server before moving on to the ...
    (borland.public.delphi.database.ado)
  • Re: SqlDataAdapter1.SelectCommand.CommandType= CommandType.StoredProcedure
    ... wenn Du nur den qualifizierten Prozedurnamen ... >> im CommandText abstellst, so wäre das der richtige Weg, ... Das ist zwar möglich aber auch nur so, da der SQL Text so nie ... vom SQL Server. ...
    (microsoft.public.de.german.entwickler.dotnet.datenbank)
  • Re: 70-229 with MSDE?
    ... I was wondering whether the MSDE version of SQL ... > Server would be sufficient for use in preparing for this exam? ... The developer version of SQL Server is good enough, ...
    (microsoft.public.cert.exam.mcad)
  • Re: 70-229 with MSDE?
    ... I was wondering whether the MSDE version of SQL ... > Server would be sufficient for use in preparing for this exam? ...
    (microsoft.public.cert.exam.mcad)