SQL Enlight Code Quality For Azure DevOps 1.8.740
Version 1.8.740 of the SQL Enlight Code Quality extension for Azure DevOps is now available.
This release introduces a dedicated task for running tSQLt unit tests directly in Azure DevOps pipelines, adding dynamic testing capabilities to the existing static code analysis features.
The sqlEnlightTestRunner task executes tSQLt tests against a target database, publishes results to Azure DevOps, and can optionally integrate them into the SQL Enlight analysis reports.
tSQLt Test Runner Task
The new sqlEnlightTestRunner@0 task connects to a SQL Server database using a connection string and executes the tSQLt test suite.
Task configuration options include:
- Publish to Test Results: Publishes test outcomes to the Azure DevOps build test results tab by setting
PublishVsTestResults: true. - Integrate with Analysis Reports: Setting
PublishJsonReport: trueappends the test execution results to the SQL Enlight analysis report. - Fail Conditions: Configures the task to fail the pipeline if any test fails (
FailOn: "anyTestFail"), or to never fail regardless of test outcomes (FailOn: "none").
Example YAML configuration for running tSQLt tests:
steps:
- task: sqlEnlightTestRunner@0
displayName: "Run tSQLt Tests"
inputs:
ConnectionString: "Server=myServerAddress;Database=myDataBase;User Id=myUsername;Password=myPassword;"
PublishVsTestResults: true
FailOn: "anyTestFail"
Store connection strings securely using Azure DevOps pipeline secrets instead of hardcoding them in YAML files.
Test Filtering
The task supports filtering to execute specific subsets of the test suite:
- Test Class Name: Runs all tests within a specific tSQLt test class.
- Test Name: Runs a single specific test by name.
- Test Filter Pattern: Uses a regular expression pattern to select tests based on their names.
If no filters are specified, the task runs all available tSQLt tests in the target database.
Pipeline Integration
You can use the sqlEnlightAnalyze@1 task for static code analysis followed by the sqlEnlightTestRunner@0 task for unit tests in the same pipeline. This allows pipelines to check both code quality standards and functional behavior.
steps:
- task: sqlEnlightAnalyze@1
displayName: "SQL Enlight Code Analysis"
env:
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
- task: sqlEnlightTestRunner@0
displayName: "Run SQL Enlight tSQLt Tests"
inputs:
ConnectionString: $(DbConnectionStringSecret)
PublishJsonReport: true
PublishVsTestResults: true
FailOn: "anyTestFail"
Availability
Version 1.8.740 is available for Azure DevOps Services and Azure DevOps Server. Install or update the extension from the Visual Studio Marketplace to use the SQL Enlight Run tSQLt Tests task in your pipelines.