11# Tests
22
3- Unit tests via [ tSQLt] ( https://tsqlt.org/ ) and Pester,
3+ Unit tests via [ tSQLt] ( https://tsqlt.org/ ) and Pester run on Appveyor ,
44code coverage by
55[ SQLCover] ( https://github.com/GoEddie/SQLCover ) and
66[ codecov.io] ( https://codecov.io/ ) , and
77linting by [ TSQLLint] ( https://github.com/tsqllint/tsqllint )
8- and [ super-linter] ( https://github.com/github/super-linter )
8+ and [ super-linter] ( https://github.com/github/super-linter ) .
9+
10+ ## How it works
11+
12+ ### tSQLt unit tests
13+
14+ Each stored procedure has all of its tSQLt unit tests stored in a single sql script in the ` \tests\ ` folder and
15+ uses the naming convention of ` sp_name.Tests.sql ` . These should mostly adhere to the following naming conventions:
16+
17+ - ` [sp_name].[test sp fails ...] `
18+ - ` [sp_name].[test sp succeeds ...] `
19+
20+ ### Pester tests
21+
22+ All of a stored proc's unit tests are run by a single corresponding Pester script, similarly
23+ named ` sp_name.Tests.ps1 ` , which:
24+
25+ - Installs the DBA MultiTool scripts
26+ - Installs the corresponding stored procedure's tSQLt tests
27+ - Runs all unit tests for the stored procedure as a single Pester invocation
28+
29+ This avoids having to hard-code or do messy querying to get each individual Pester test for a stored procedure
30+ at the expense of obfuscating more detailed output (i.e. one failed test among 20 counts as a full falure in Appveyor).
31+
32+ The output is printed in each [ Appveyor] ( https://ci.appveyor.com/project/LowlyDBA/dba-multitool ) job if a failure needs to be inspected.
33+
34+ ### Appveyor
35+
36+ Each Pester test is then run against each configuration defined in ` \appveyor\appveyor.yml ` in order
37+ to test against all supported SQL Server versions. These are auto-triggered for each commit made in a pull request.
938
1039## How to run
1140
@@ -14,22 +43,18 @@ and [super-linter](https://github.com/github/super-linter)
1443The following prereqs are * not* handled by the setup script:
1544
1645* SQL Server 2012+ or equivalent
17- * tSQLt installed on a database (install scripts located in ` tests\tSQLt\ ` if needed )
46+ * tSQLt installed on a database (run ` appveyor\install_tsqlt.ps1 ` manually )
1847
1948### Steps
2049
21501 . Temporarily update ` tests\constants.ps1 ` with any values
2251specific to your local environment (Instance and Database)
2352
24- 2 . Run the following PowerShell from the project root:
25-
26- ``` powershell
27- .\tests\localdev_test.ps1
28- ```
53+ 2 . Run the following PowerShell from the project root ` tests\localdev_test.ps1 `
2954
3055This will:
3156
3257* Install all dependencies (except a tSQLt database)
3358* Produce an html code coverage report on completion in a popup browser
3459
35- To skip the automated setup, use the flag ` -SkipSetup ` when running the script.
60+ To skip the automated setup of dependencies , use the flag ` -SkipSetup ` when running the script.
0 commit comments