Skip to content

Instantly share code, notes, and snippets.

@scivision
Created February 17, 2021 20:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scivision/543a7fe2746379960959d78018963762 to your computer and use it in GitHub Desktop.
Save scivision/543a7fe2746379960959d78018963762 to your computer and use it in GitHub Desktop.
Matlab CI on Azure Pipelines
pool:
vmImage: ubuntu-latest
steps:
- task: InstallMATLAB@0
- task: RunMATLABCommand@0
inputs:
command: TestAll
- task: PublishTestResults@2
condition: succeededOrFailed()
inputs:
testResultsFiles: test-results/results.xml
- task: PublishCodeCoverageResults@1
inputs:
codeCoverageTool: Cobertura
summaryFileLocation: code-coverage/coverage.xml
% 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);
mkdir('code-coverage');
mkdir('test-results');
runner.addPlugin(XMLPlugin.producingJUnitFormat('test-results/results.xml'));
runner.addPlugin(CodeCoveragePlugin.forPackage(name, 'Producing', CoberturaFormat('code-coverage/coverage.xml')));
results = runner.run(suite);
assert(~isempty(results), "no tests found")
assertSuccess(results)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment