SQLTest_QuickReferenceGuide
SQLTest_QuickReferenceGuide
Tests can be grouped together within a schema Checks to see if an object with the specified name
exists in the database.
– allowing you to organize your tests and use AdventureWorks Example Test
tSQLt.AssertObjectExists [@ObjectName = ] 'object name'
common setup methods. [, [@Message = ] 'message' ] CREATE PROCEDURE [MyNewTestClass].[test update employee]
AS
BEGIN
Results can be output as text or JUnit XML AssertResultSetsHaveSameMetaData EXEC tSQLt.FakeTable 'HumanResources.Employee';
– making it easier to integrate with a continuous Compares the meta data (column names and
INSERT INTO HumanResources.Employee (EmployeeID, Gender)
VALUES (0, 'M');
integration tool. properties) of results for two commands. EXEC HumanResources.uspUpdateEmployeePersonalInfo
tSQLt.AssertResultSetsHaveSameMetaData @EmployeeID = 0,
Mocking features to fake tables and views, and [@expectedCommand = ] 'expected command'
@NationalIDNumber = NULL,
@BirthDate = NULL,
create stored procedure spies – allowing you to @MaritalStatus = NULL,
@Gender = 'F';
isolate the code which you are testing. Fail
Simply fails a test case with the specified failure DECLARE @ActualGender CHAR(1);
SET @ActualGender = (SELECT Gender FROM HumanResources.Employee);
message.
EXEC tSQLt.AssertEquals @Expected = 'F', @Actual = @ActualGender;
tSQLt.Fail [ [@Message0 = ] message part ] END;