Switch from SQL CI Test command to PowerShell
Published 10 March 2016
This page shows you how to create a PowerShell script using the DLM Automation cmdlets that's equivalent to the SQL CI Test command.
The SQL CI Test command runs tSQLt tests against the NuGet package created by the Build command.
This example uses the Test command in SQL CI to create test results in the folder c:\testresults:
Command line example
sqlCI.exe Test /package="C:\packages\WidgetShop.1.0.nupkg" /outputFolder="c:\testresults"
Here's the same example using the DLM Automation PowerShell cmdlets:
PowerShell example
$package = "C:\packages\WidgetShop.1.0.nupkg" $results = $package | Invoke-DlmDatabaseTests $results | Export-DlmDatabaseTestResults -OutputFile "C:\testresults\WidgetShop.junit.xml" $results | Export-DlmDatabaseTestResults -OutputFile "C:\testresults\WidgetShop.trx"
In the example above:
- On line 2, Invoke-DlmDatabaseTestsruns the tests.
- On line 3, Export-DlmDatabaseTestResultsexports the results to disk in JUnit format.
- On line 4, Export-DlmDatabaseTestResultsexports the results to disk in MSTest format.
The file name and format for the test results are specified by the -OutputFile parameter of Export-DlmDatabaseTestResults.