Friday

t-sql unit testing

Here is simple t-sql unit testing approach by writing sql script that will do all testing work.
I like this solution the most because it's very flexible and doesn't require additional installations on sql server.


Also I think the best way to write sql unit tests is to make them independent from data.And validate logic but not data.
Such unit tests can be run on development or qa and even production environment.
 
--Unit Test example
--SETUP
declare @ActualData varchar(10) , @ExpectedResult varchar(10)

-- RUN
SET @ActualData ='a'
Set @ExpectedResult ='b'

-- VALIDATE
IF @ActualData!= @ExpectedResult
RAISERROR('>> Unit Test FAILED: Returned data doen''t match expected: %s instead of %s ', 11, 0, @ActualData ,@ExpectedResult )

Also there are another sql unit test frameworks .

No comments:

imagemagic add text to image

rem different types of text annotations on existing images rem cyan yellow orange gold rem -gravity SouthWest rem draw text and anno...