Invoke-DevartDatabaseTests

Synopsis

Runs tSQLt tests for a specified database.

Description

The cmdlet runs the tSQLt tests from the database project and can generate a separate report with the results.

Syntax

Invoke-DevartDatabaseTests -InputObject <object> [-Class <string>] [-DataGeneratorProject <string>] [-FilterPath <string>] [-IncludeTestData <SwitchParameter>] [-InstalltSQLtFramework <SwitchParameter>] [-OutReportFileName <string>] 
[-QueryBatchTimeout <int>] [-ReportFormat <TestReportFormat>] [-RewriteReport <SwitchParameter>] [-SynchronizationOptions <string>] [-TemporaryDatabaseServer <object>] [-UnInstalltSQLtFramework <SwitchParameter>] [-UnitTests <string>] 
[<CommonParameters>]

Parameters

-InputObject

Specifies the database on which to run the tSQLt tests. This can be a scripts folder, a NuGet package, or a database connection.

-InputObject <object>
Property Default value
Required True
Position Named
Default value -
Accept pipeline input False
Accept wildcard characters False

-InstalltSQLtFramework

Installs a tSQLt Framework before executing tests.

-InstalltSQLtFramework <SwitchParameter>
Property Default value
Required False
Position Named
Default value False
Accept pipeline input False
Accept wildcard characters False

-UnInstalltSQLtFramework

Uninstalls a tSQLt Framework after executing tests.

-UnInstalltSQLtFramework <SwitchParameter>
Property Default value
Required False
Position Named
Default value False
Accept pipeline input False
Accept wildcard characters False

-RewriteReport

Overwrites a report file.

-RewriteReport <SwitchParameter>
Property Default value
Required False
Position Named
Default value False
Accept pipeline input False
Accept wildcard characters False

-Class

Executes tests for the specified class; otherwise, runs all tests.

-Class <string>
Property Default value
Required False
Position Named
Default value -
Accept pipeline input False
Accept wildcard characters False

-UnitTests

Runs a specific test or test suite; otherwise, runs all tests.

-UnitTests <string>
Property Default value
Required False
Position Named
Default value -
Accept pipeline input False
Accept wildcard characters False

-OutReportFileName

Specifies the destination file path for exporting test results.

-OutReportFileName <string>
Property Default value
Required False
Position Named
Default value -
Accept pipeline input False
Accept wildcard characters False

-ReportFormat

Specifies the format of the test results file.

-ReportFormat <TestReportFormat>
Property Default value
Possible values JUnit, MsTest
Required False
Position Named
Default value JUnit
Accept pipeline input False
Accept wildcard characters False

-IncludeTestData

Populates the database with test data. Use the DataGeneratorProject parameter to specify the data source.

-IncludeTestData <SwitchParameter>
Property Default value
Required False
Position Named
Default value False
Accept pipeline input False
Accept wildcard characters False

-DataGeneratorProject

Specifies a data generation project file (.dgen) that defines the data to insert into the test database.

-DataGeneratorProject <string>
Property Default value
Required False
Position Named
Default value -
Accept pipeline input False
Accept wildcard characters False

-SynchronizationOptions

Specifies the schema comparison options to generate a synchronization script.

-SynchronizationOptions <string>

To include additional options, specify a list of the options, for example:

/IgnoreCase:Yes /IgnorePrimaryKeys:No
Property Default value
Required False
Position Named
Default value -
Accept pipeline input False
Accept wildcard characters False

For a complete list of synchronization options, see Command-line options.

-TemporaryDatabaseServer

Specifies the connection to the temporary database. This parameter can be used if a script folder, an object, or a NuGet package is specified as -InputObject. Otherwise, the parameter is ignored.

-TemporaryDatabaseServer <object>
Property Default value
Required False
Position Named
Default value -
Accept pipeline input False
Accept wildcard characters False

-QueryBatchTimeout

Controls how long a SQL query can run before PowerShell stops it. This parameter applies to each expression in the database creation script when the Connection parameter is a DevartDatabaseConnectionInfo object.

  • Temporary database creation script
  • Data generation script
  • Testing script
-QueryBatchTimeout <int>
Property Default value
Required False
Position Named
Default value 30
Accept pipeline input False
Accept wildcard characters False

-FilterPath

Specifies the schema comparison filter options used when generating the test database.

-FilterPath <string> 
Property Default value
Required False
Position Named
Default value -
Accept pipeline input False
Accept wildcard characters False

Common parameters

<CommonParameters>

This cmdlet supports these common parameters:

  • Verbose – Provides detailed output about the command operation.
  • Debug – Provides debugging information.
  • ErrorAction – Specifies how to respond to errors.
  • ErrorVariable – Stores error messages in a variable.
  • WarningAction – Specifies how to respond to warnings.
  • WarningVariable – Stores warning messages in a variable.
  • InformationAction – Specifies how informational messages are handled.
  • InformationVariable – Stores informational messages in a variable.
  • OutBuffer – Controls the number of objects buffered before output.
  • PipelineVariable – Stores the current pipeline object in a variable.
  • OutVariable – Stores output objects in a variable.

For more information, see About Common Parameters.

Output

System.Boolean (returns true on success and false otherwise)

System.Boolean returns:

  • true if the operation was successful.
  • false if the operation failed.

Example

$testResult = Invoke-DevartDatabaseTests -InputObject $connection -InstalltSQLtFramework -IncludeTestData -DataGeneratorProject "DatabaseName(MsSqlServer).dgen" -OutReportFileName "C:\TestResult.xml" -ReportFormat JUnit -RewriteReport

Related links

For information about how to generate a file containing filter options, see Using Object Filter.

For information on additional command-line options, see Automate SQL unit testing from the command line and Generate data.