Skip to content

sanderstad/SSDT-With-tSQLt-Template

Repository files navigation

SSDT-With-tSQLt-Template

Template how a SSDT project can be setup including tSQLt

To use this template you need the PSModuleDevelopment module which is part of the PSFramework project

Generate the solution

Use the following command to create a new template from this directory

New-PSMDTemplate -ReferencePath [pathtofolder] -TemplateName [nameoftemplate]

i.e.

New-PSMDTemplate -ReferencePath C:\Users\sande\source\repos\Databases\SSDT-With-tSQLt-Template -TemplateName SSDTWithtSQLt

To create a new solution from the template use the following command

Invoke-PSMDTemplate -TemplateName [nameoftemplate] -OutPath [path-to-output-to] -Name [nameofproject]

i.e.

Invoke-PSMDTemplate -TemplateName SSDTWithtSQLt -OutPath C:\Users\sande\source\repos\Databases -Name DatabaseProject1

For more guidance on the template system, visit the documentation pages for the module

Generate basic tests for your database

Look for the functionality to create basic tSQLt unit tests for this solution to the module "PStSQLtTestGenerator".

To install for everyone

Install-Module PStSQLtTestGenerator

To install for current user

Install-Module PStSQLtTestGenerator -Scope CurrentUser

To create the unit tests

Invoke-PSTGTestGenerator -SqlInstance [yourinstance] -Database [yourdatabase] -OutputPath [path to SSDT project test folder]