Run tSQLt Unit TestsWhat's new
DescriptionWith this build task, besides running tSQLt Unit Tests on a SQL Database, you'll also be able to:
Originally, there is no build task that does all those 3 tasks. Thinking from an automation and engineering perspective, once you run your unit tests, it would be good to have its results published somewhere to inspect and adapt your tests. This task relies on 3 components: SQLCoverLink: https://github.com/GoEddie/SQLCover This is an Open Source component written by Ed Elliot to extract code coverage from a tSQLt test execution. OpenCover to Cobertura ConverterLink: https://github.com/danielpalme/OpenCoverToCoberturaConverter An Open Source tool written by Daniel Palme to convert OpenCover code coverage reports to Cobertura, a coverage report supported by Azure DevOps. See more here. Report GeneratorLink: https://github.com/danielpalme/ReportGenerator Daniel Palme also wrote a tool to convert XML Code Coverage reports into human readable reports in various formats. FlowBasically, this extension performs the following tasks, in order:
PreviewThis extension is still in preview to gather information on using, feedback and tracking initial issues. How to use itTL;DRIf you just want your test (with or without Code Coverage) and you will not customize anything right now, just follow these steps:
Add the Run tSQLt Unit Tests build task to your pipelineSearch for General configurationThe only important thing here is to highlight that the working directory for the task will be the build sources directory. You can change this but it's recommended to keep it as it is. Database InformationHere, two required information:
Test ExecutionYou'll have default information filled here that is supposed to make it work by default with the requirements of the Publish Test Results task. You can also customize it.
Code CoverageBy default, Code Coverage is disabled. If you want the task to also generate Cobertura code coverage reports, you must enable it. Remember that all those paths are relative to working directory\root folder
Control optionsVERY IMPORTANT If any of your tests fail, the task will also fail. Because of that, you must mark the Continue on error option so your pipeline will publish test results and code coverage reports, if enabled. Add the Publish Test Results to the pipelineTo have the test results available on the pipeline summary, you must publish it. To do that, you just need to use the Publish Test Results task: Configure important parameters
Add the Publish Code Coverage Results task (if Code Coverage Enabled)If you enabled Code Coverage on the Tests task, you'll need to publish its results to the pipeline summary.
|