ApexSQL Unit Test Command Line Interface (CLI) switches

Applies to

ApexSQL Unit Test

Summary

This article explains the ApexSQL Unit Test CLI switches, and their usage through the examples.

Description

Connection switches

/server

Specifies server and instance name of the SQL instance. It will reference to (local) SQL Server if the switch is omitted

Alias: /s

Format: /server:server_name[\instance_name]

/database

Specifies the unit tests database name

Alias: /d

Format: /database:database_name

/user

Specifies the Server login when SQL Server authentication is used. The trusted connection will be used if the switch is omitted

Alias: /u

Format: /user:server_login

Note: This switch must be used together with the /password switch

/password

Specifies the Server login’s password when SQL Server authentication is used.

Alias: /p

Format: /password:server_login_password

Note: This switch must be used together with the /user switch

Specific switches

/class

Specifies the unit test class that contains tests that will be executed. If a class is not specified or empty, all tests present on the chosen database will be executed

Alias: /cl

Format: /class:class_name

/utests

Specifies a unit test list where unit tests are separated by one space and which name must start with test. Example: /ut:testAB testBC testCD

Alias: /ut

Format: /utests:unit_test_name

Note: Test names must be written properly including capital and small letters

/install_tsqlt

Install the latest built-in version of tSQLt framework on a specified database before executing tests

Alias: /it

Format: /install_tsqlt

/install_sqlcop

Install built-in SQLCop tests on a specified database before executing tests

Alias: /isc

Format: /install_sqlcop

Note: This switch must be used together with the /install_tsqlt

/uninstall_tsqlt

Uninstall tSQLt framework on a specified database

Alias: /utf

Format: /uninstall_tsqlt

Note: Using this switch without the /uninstall_classes switch will leave all test classes in a specified database

/uninstall_classes Uninstall all test classes on database

Alias: /dc

Format: /uninstall_classes

Note: This switch cannot be used alone, must be used with the /uninstall_tsqlt switch

/delete_class

Specifies which test class will be deleted from a specified database

Alias: /dcn

Format: /uninstall_class:class_name

Reporting switches

/outreport

Specifies that tests results will be exported to XML or SQL file

Alias: /or

Format: /outreport:file_path

/to_database

Specifies that tests results summary will be exported to a database

Alias: /todb

Format: /to_database

Note: This switch must be used with switches /export_server and /export_database

/export_server

Specifies SQL Server where the tests result summary will be exported. It will reference to (local) SQL Server if the switch is omitted

Alias: /exs

Format: /export_server: server_name[\instance_name]

Note: This switch must be used with switches /to_database and /export_database

/export_database

Specifies a database where the tests result summary will be exported.

Alias: /exd

Format: /export_database:exportdatabasename

Note: This switch must be used with switches /to_database and /export_server

/export_user

Specifies the SQL Server login when SQL Server authentication is used. The trusted connection will be used if the switch is omitted.

Alias: /exu

Format: /export_user:export_user

Note: This switch must be used together with the /password switch

/export_password

Specifies the Server login’s password when SQL Server authentication is used.

Alias: /exp

Format: /export_password:export_server_password

Note: This switch must be used together with the /user switch

More information about Additional switches and Common Return codes can be found in General usage and the common Command Line Interface (CLI) switches for ApexSQL tools article.

Examples

Installing built-in tSQLt framework with built-in SQL Cop tests and running those tests:

ApexSQLUnitTest.com /s:M5KY25\SQLS17 /d:AdventureWorks2017 /it /isc

Running specified unit tests from a specified class:

ApexSQLUnitTest.com /s:M5KY25\SQLS17 /d:AdventureWorks2017 /cl:Tables /ut:testAuto close testAuto Shrink

Running unit tests against a database specified in the argument file, e.g. “ArgFile.xml”:

ApexSQLUnitTest.com /argfile:”C:\Users\<user>\Documents\ApexSQL\ApexSQL Unit Test\ArgFile.xml”

Deleting one class from a database and running all other tests in a database:

ApexSQLUnitTest.com /s:M5KY25\SQLS17 /d:AdventureWorks2017 /dcn:Views

Deleting one class from a database and running specific class tests:

ApexSQLUnitTest.com /s:M5KY25\SQLS17 /d:AdventureWorks2017 /cl:Tables /ut:testAuto close testAuto Shrink /dcn:Views

Exporting the tests result summary to XML or SQL file:

ApexSQLUnitTest.com /s:M5KY25\SQLS17 /d:AdventureWorks2017 /cl:Tables /ut:testAuto close testAuto Shrink /or:”C:\Users\<user>\Documents\ApexSQL\ApexSQL Unit Test\Results.xml”

ApexSQLUnitTest.com /s:M5KY25\SQLS17 /d:AdventureWorks2017 /cl:Tables /ut:testAuto close testAuto Shrink /or:”C:\Users\<user>\Documents\ApexSQL\ApexSQL Unit Test\Results.sql”

Exporting the tests result summary to a database on a different SQL Server on the same machine:

ApexSQLUnitTest.com /s:M5KY25\SQLS17 /d:AdventureWorks2017 /cl:Tables /ut:testAuto close testAuto Shrink /todb /exs: M5KY25\SQLS19 /exd: AdventureWorks2017

Uninstalling tSQLt framework and all unit tests from a database:

ApexSQLUnitTest.com /s:M5KY25\SQLS17 /d:AdventureWorks2017 /utf /dc