-
Notifications
You must be signed in to change notification settings - Fork 113
Expand file tree
/
Copy pathtab.sqlpromptsnippet
More file actions
77 lines (65 loc) · 5.88 KB
/
tab.sqlpromptsnippet
File metadata and controls
77 lines (65 loc) · 5.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<?xml version="1.0" encoding="utf-16"?>
<CodeSnippets>
<CodeSnippet Format="1.0.0">
<Header>
<Title>tab</Title>
<Shortcut>tab</Shortcut>
<Description>tSQLt: about [tSQLt - Database Unit Testing for SQL Server. Get it at http://tsqlt.org]</Description>
<Author />
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Declarations />
<Code Language="sql"><![CDATA[/*
-----------------
-- About tSQLt --
-----------------
tSQLt is an open source unit testing framework for SQL Server.
tSQLt is coauthored by:
- Dennis Lloyd Jr. ( @dennislloydjr | http://curiouslycorrect.com/ )
- Sebastian Meine ( @sqlity | http://sqlity.net )
You can download tSQLt at http://tSQLt.org/downloads
A more complete set of SQL Prompt snippets is available there too.
tSQLt provides an array of procedures that help you to write robust test cases
by isolating dependencies (e.g. tSQLt.FakeTable or tSQLt.SpyProcedure) and
asserting correct behavior (e.g. tSQLt.AssertEqualsTable or tSQLt.ExpectException).
To create a test, you first need to create a schema using the tSQLt.NewTextClass
procedure. Any procedure that lives in such a schema and that has a name that
begins with the four letters "test" is considdered a test case. To execute a test
just run tSQLt.Run passing in either the schema name or the fully qualified
test case name. To execute all test cases in the database run tSQLt.RunAll
You can find the tSQLt manual and examples at http://tsqlt.org/user-guide/
To check the version of tSQLt that is currently installed execute this query:
SELECT * FROM tSQLt.Info();
The Version and the ClrVersion should always match.
For an easier way to manage and execute your tests check out Red Gate SQL Test.
Below is a test case template that also explains the three parts that every
test should contain.
*/
GO
-- Comments here are associated with the test.
-- For test case examples, see: http://tsqlt.org/user-guide/tsqlt-tutorial/
CREATE PROCEDURE [<Test_Class,sysname,>].[<Test_Name,sysname,test >]
AS
BEGIN
--Assemble
-- This section is for code that sets up the environment. It often
-- contains calls to methods such as tSQLt.FakeTable and tSQLt.SpyProcedure
-- along with INSERTs of relevant data.
-- For more information, see http://tsqlt.org/user-guide/isolating-dependencies/
--Act
-- Execute the code under test like a stored procedure, function or view
-- and capture the results in variables or tables.
--Assert
-- Compare the expected and actual values, or call tSQLt.Fail in an IF statement.
-- Typical Asserts: tSQLt.AssertEquals, tSQLt.AssertEqualsString, tSQLt.AssertEqualsTable
-- For a complete list, see: http://tsqlt.org/user-guide/assertions/
EXEC tSQLt.Fail 'TODO:Implement this test.'
END;
GO
]]></Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>