Matlab with Azure CI

Matlab CI services include Azure Pipelines. Matlab Azure Pipelines CI is useful to automatically unit test Matlab code on each “git push” as with other coding languages. We use an “azure-pipelines.yml” file in the Git repo to control CI behavior. A top-level file named like “TestAll.m” is also needed to control CI run.

Matlab azure-pipelines.yml

This azure-pipelines.yml file will test a Matlab project on Azure Pipelines CI at no cost. It can be useful to specify a specific Matlab version to ensure a baseline Matlab version compatibility. For example, specify the older Matlab version the project must support, as developers typically use newer Matlab versions and may inadvertently use Matlab functions only available in newer Matlab versions than some users or project requirements specify.

  vmImage: ubuntu-latest
  - task: InstallMATLAB@0
      release: R2020a
  - task: RunMATLABCommand@0
      command: TestAll
  - task: PublishTestResults@2
    condition: succeededOrFailed()
      testResultsFiles: test-results/results.xml
  - task: PublishCodeCoverageResults@1
      codeCoverageTool: Cobertura
      summaryFileLocation: code-coverage/coverage.xml

A file at the top level with name like TestAll.m is also necessary, with contents like:

% this script is run on Azure (or local)
import matlab.unittest.TestRunner
import matlab.unittest.Verbosity
import matlab.unittest.plugins.CodeCoveragePlugin
import matlab.unittest.plugins.XMLPlugin
import matlab.unittest.plugins.codecoverage.CoberturaFormat

name = "MyProject";

suite = testsuite(name);
runner = TestRunner.withTextOutput('OutputDetail', Verbosity.Detailed);


runner.addPlugin(CodeCoveragePlugin.forPackage(name, 'Producing', CoberturaFormat('code-coverage/coverage.xml')));

results =;
assert(~isempty(results), "no tests found")



We have several projects using Azure Pipelines with Matlab. It’s often useful to start from a known-working example as below: