Using the test command
Published 20 July 2016
Running tSQLt tests
If you want to run tSQLt tests against the package, you'll need to enable the common language runtime (CLR) integration feature on the /temporaryDatabaseServer. For more information, see Enabling CLR Integration (TechNet article).
To run the SQL CI command line test step, use this syntax:
sqlCI.exe Test /package=<value1> /temporaryDatabaseServer=<value2>
Example
sqlCI.exe Test /package=WidgetShop\Database\Output\WidgetShop.1.0.nupkg /temporaryDatabaseServer=(localdb)\v11.0
Here are details of all the test command switches:
/package
The path to the package that was created in the build step.
Example
/package=WidgetShop\Database\Output\WidgetShop.1.0.nupkg
Contents:
/temporaryDatabaseServer (optional)
The temporary database server name.
Example
/temporaryDatabaseServer=SQLServer2012
During the test step, SQL CI makes a copy of your database on a temporary server in order to run the tSQLt tests. By default, it uses LocalDB for this.
If your database uses features that are not supported by LocalDB, such as Full-Text Search, you can use this switch to specify the name of an alternative temporary server for the copy of the database.
For more information on LocalDB, see SQL Server 2012 Express LocalDB (MSDN article).
/temporaryDatabaseName (optional)
The name of an existing database on the temporary database server you previously specified.
Example
/temporaryDatabaseName=WidgetShopTemp
During the test step, SQL CI recreates your database on a temporary server. You should use an empty database for this, because data will be overwritten during the build step.
You should only use this switch if:
- you don't have permissions to create databases on your SQL server
- you don't plan to run multiple builds in parallel that use the same temporary database. You must use a separate database for each build definition
If you don't use this switch, SQL CI will create a temporary database by default.
/temporaryDatabaseUserName (optional)
The username for SQL authentication.
Example
/temporaryDatabaseUserName=sa
If you don't specify this switch, Windows authentication is used by default.
/temporaryDatabasePassword (optional)
The password for SQL authentication.
Example
/temporaryDatabasePassword=password
/outputFolder (optional)
The output folder for test results.
Example
/outputFolder=c:\testresults
If you don't specify this switch, the current working directory is used by default.
/sqlDataGenerator (optional)
Use test data created by SQL Data Generator. If you've already created a SQL Data Generator project file, include the file name.
Example
/sqlDataGenerator=TestData.sqlgen
If you don't have an existing project file, include this switch without specifying a value. This will populate the temporary database with test data that's been generated automatically. For more information about SQL Data Generator, see SQL Data Generator 3 documentation.
/additionalCompareArgs (optional)
Specifies additional command line switches to pass through to SQL Compare.
For example, to abort an operation when there are changes that might result in data loss, pass through the /AbortOnWarnings
switch like this:
Example
/additionalCompareArgs="/AbortOnWarnings:Medium"
The switch values should always be surrounded by double quotes.
SQL CI already uses SQL Compare's /Options
switch with its own set of default values. To include additional options, use the following syntax:
Example
/additionalCompareArgs="/Options:DoNotOutputCommentHeader,ForceColumnOrder"
The option values are not case sensitive.
You can also use aliases if you prefer shorthand versions of the options. For details of the alias for each option, see Options used in the command line (SQL Compare Documentation).
Example
/additionalCompareArgs="/Options:nc,f"
To exclude options, prefix the option with a minus sign. For example:
Example
/additionalCompareArgs="/Options:-IncludeDependencies,-IgnoreWhiteSpace"
The default options (with aliases in brackets) used for data comparison are:
- DecryptPost2KEncryptedObjects (dp2k)
- IgnoreFillFactor (if)
- IgnoreWhiteSpace (iw)
- IncludeDependencies (incd)
- IgnoreFileGroups (ifg)
- IgnoreUserProperties (iup)
- IgnoreWithElementOrder (iweo)
- IgnoreDatabaseAndServerName (idsn)
- UseCompatibilityLevel (ucl)
You can include some options and exclude others. For example:
Example
/additionalCompareArgs="/Options:IgnoreConstraintNames,NoTransactions,-IgnoreFillFactor"
If the switch value contains double quotes, you need to escape them with a backslash. For example, if the switch value is /TIL:"READ COMMITTED", use the following syntax:
Example
/additionalCompareArgs="/TIL:\"READ COMMITTED\""
If you're running sqlCI.exe in PowerShell, you must also insert the backtick character (ASCII 96) to escape each double quote. For example:
/additionalCompareArgs="/TIL:\`"READ COMMITTED\`""
For more information, see Windows PowerShell: about_Escape_Characters (TechNet article).
If you don't insert the correct escape characters, the switch value will be invalid.
For more information about SQL Compare command line options and switches, see Using the command line.
/licenseSerialKey (optional)
To activate the DLM Automation license on the machine the build agent is running on, enter the serial number.
Example
/licenseSerialKey=123-456-789012-ABCD
For information on finding your DLM Automation serial number, see Legacy licensing. If you don't enter a serial number, a 28 day free trial of the DLM Automation will start automatically.
If you have multiple serial numbers, separate them using commas without spaces.
Example
/licenseSerialKey=123-456-789012-ABCD,321-456-987654-DCBA
/runOnly (optional)
To run a specific test class or test instead of every test, enter the test class and test name.
Example
/runOnly=[testclass].[testname]
If you want to run every test, don't specify this switch.