Matlab Run Tests
MathWorksOfficialCreated by MathWorks
- Skill
- Tool integration
- Software development
- BSD-2-Clause
- No issues found
AutoGineer summary
Written by AutoGineer from the skill’s own files, not by the author
This skill provides a structured workflow for running and managing MATLAB test suites. It covers test execution, filtering, parallel processing, and diagnostic reporting. Additionally, it details how to collect and analyze code coverage metrics, including statement, decision, condition, and MC/DC levels, as well as data type and size coverage. It also supports CI/CD integration using MATLAB buildtool.
What it does
- Executes MATLAB test suites with support for filtering by name, tag, or folder.
- Provides diagnostic reporting for failed or incomplete test results.
- Configures code coverage collection using plugins to measure statement, decision, condition, and MC/DC metrics.
- Extracts and analyzes data type and size coverage for function inputs.
- Integrates with CI/CD pipelines using buildfile.m and buildtool.
- Supports parallel test execution to improve performance.
When to use it
- When you need to run an existing MATLAB test suite.
- When you need to verify code coverage metrics for your source code.
- When you are setting up or configuring CI/CD pipelines for MATLAB projects.
- When you need to diagnose why specific tests are failing or incomplete.
- When you need to filter large test suites to run only relevant tests.
Advantages
- Enables programmatic control over test execution and reporting.
- Provides granular visibility into code coverage and testing gaps.
- Facilitates automated testing workflows within CI/CD environments.
- Supports advanced coverage metrics like MC/DC and data type/size analysis.
Usage examples
- “Run all tests in the 'tests' folder using parallel execution.”
- The agent will execute runtests('tests', UseParallel=true) and report the pass/fail results.
- “Collect MC/DC coverage for the 'src' folder.”
- The agent will set up a TestRunner with a CodeCoveragePlugin, run the tests, and output the coverage summary.
- “Show me which tests failed in my last run.”
- The agent will iterate through the results array, identify failed tests, and display their diagnostic records.
- “How do I configure a buildfile for my CI pipeline?”
- The agent will provide a template for buildfile.m including a TestTask and instructions for CI integration.
Install
Download the skill as a ZIP:
https://autogineer.com/agent-skills/matlab/matlab-run-tests/downloadUnzip it into the cross-client skills folder of your project:
mkdir -p .agents/skills && unzip matlab-run-tests.zip -d .agents/skills
Documentation by MathWorks
Run Tests
Run MATLAB test suites, analyze results, collect code coverage metrics, and configure CI/CD pipelines using matlab.unittest infrastructure.
When to Use
User wants to run an existing test suite
User needs to filter tests by name, tag, or folder
User wants to analyze test failures or incomplete results
User needs code coverage collection or analysis
User wants CI/CD pipeline configuration with buildtool
User asks about parallel test execution
When NOT to Use
Writing tests, creating test classes, parameterization, fixtures, mocking — use
matlab-write-testsBaseline/regression tests against stored reference data — use
matlab-write-testsTesting Simulink models — use Simulink test skills
Performance benchmarking — use profiling workflows
Workflow
Run and report
Run tests — Execute via
run_matlab_test_fileMCP tool orruntestswith filteringAnalyze results — Report pass/fail counts, iterate failed tests for diagnostics
Verify — Confirm all tests pass before proceeding to coverage or CI
Coverage analysis (when requested)
Collect — Set up
TestRunnerwithCodeCoveragePluginandCoverageResultReport summary — Call
coverageSummaryand present percentages to userAct on results — Generate reports, analyze gaps, or justify — as user directs
CI/CD setup
Create buildfile.m — Define
TestTaskwith source and report optionsAdd CI config — GitHub Actions, Azure DevOps, or GitLab CI template
Running Tests
Via MCP
Use the run_matlab_test_file MCP tool to run test files directly. When you need filtering, parallel execution, or other options, use evaluate_matlab_code with runtests:
results = runtests('tests'); % all tests in folder
results = runtests('tests', Tag='Unit'); % by tag
results = runtests('tests', Name='*Calculator*'); % by name pattern
results = runtests('tests', UseParallel=true); % parallel execution
results = runtests('tests', Strict=true); % warnings = failuresAnalyzing Results
disp(results);
for r = results([results.Failed])
fprintf('\nFAILED: %s\n', r.Name);
disp(r.Details.DiagnosticRecord.Report);
end
for r = results([results.Incomplete])
fprintf('\nINCOMPLETE: %s\n', r.Name);
disp(r.Details.DiagnosticRecord.Report);
endCoverage Analysis
import matlab.unittest.TestRunner
import matlab.unittest.plugins.CodeCoveragePlugin
import matlab.unittest.plugins.codecoverage.CoverageResult
runner = TestRunner.withTextOutput;
covFormat = CoverageResult;
runner.addPlugin(CodeCoveragePlugin.forFolder('src', ...
IncludingSubfolders=true, Producing=covFormat, MetricLevel='mcdc'));
results = runner.run(testsuite('tests'));
covResults = covFormat.Result;
summary = coverageSummary(covResults, "mcdc");
fprintf('Coverage: %d/%d (%.1f%%)\n', sum(summary(:,1)), sum(summary(:,2)), ...
100*sum(summary(:,1))/sum(summary(:,2)));For detailed coverage workflows — gap analysis, justifications, generated C code coverage, and data type/size coverage — see references/code-coverage-guidance.md.
Key Functions
| Category | Functions | Purpose |
|---|---|---|
| Execution | runtests, TestSuite, TestRunner | Run and organize tests |
| Coverage | CodeCoveragePlugin, CoverageResult, coverageSummary | Measure test coverage |
| Reports | CoverageReport, generateStandaloneReport, generateCoberturaReport | Coverage output formats |
| CI/CD | buildtool, TestTask, addCodeCoverage | Pipeline automation |
| Scripts | printCoverageGaps | Print all uncovered items across metric levels — see references/code-coverage-guidance.md for interface |
CI/CD Integration
Use buildtool with a buildfile.m for CI pipelines. See references/test-execution-guidance.md for buildfile.m templates and CI configs (GitHub Actions, Azure DevOps, GitLab CI).
For toolbox projects, matlab-package-toolbox generates a buildfile.m in which the packaging task depends on the test task.
References
Load these on demand — most test runs only need what's in this file.
| Load when... | Reference |
|---|---|
| Running tests in CI, buildtool config, filtering options, parallel execution details | references/test-execution-guidance.md |
| Collecting code coverage (MC/DC, statement, decision, condition), analyzing gaps, justifying uncovered code, generated C code coverage, type-size coverage | references/code-coverage-guidance.md |
| Creating or modifying filter rule XML for coverage justifications | references/justification-filter-rules.md |
| Extracting data type and size coverage results from hidden property | references/datatype-size-extraction.md |
Conventions
Always: run tests via the
run_matlab_test_fileMCP tool when possibleAlways: report pass/fail summary before taking further action
Always: check for Failed/Incomplete tests before analyzing coverage
Prefer:
forFolderwithIncludingSubfolders=trueas the default source specification for coveragePrefer: MC/DC as the default metric level because each level includes all lower levels
Never: generate coverage reports (HTML, Cobertura) unless the user explicitly requests them
Never: use
CoverageResultas the only format — always use it as the primary programmatic format
Copyright 2026 The MathWorks, Inc.
Files
- ATTRIBUTION.mdAdded by AutoGineer1.0 KiB
- LICENSELicence file added by AutoGineer1.4 KiB
- SKILL.md6.3 KiB
- manifest.yaml472 B
- references/code-coverage-guidance.md14.6 KiB
- references/datatype-size-extraction.md4.8 KiB
- references/justification-filter-rules.md4.7 KiB
- references/test-execution-guidance.md2.8 KiB
- scripts/printCoverageGaps.m3.0 KiB
manifest.yaml
schema-version: 1 license: https://www.mathworks.com/content/dam/mathworks/license/pmrl/license.md scope: cross-product version: "1.1" human-description: Run MATLAB test suites, collect code coverage, and configure CI/CD pipelines. matlab-release: ">=R2021a" toolkit: matlab-agentic-toolkit required-products: [] optional-products: - MATLAB Test required-tools: - evaluate_matlab_code - run_matlab_test_file required-skills: [] # Copyright 2026 The MathWorks, Inc.
Requirements and compatibility
Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta
“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.
Security
No issues found by our static scan· No issues found
A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.
Attribution and licence
- Created by
- MathWorks
- Publisher
- MathWorks (Official)
- Source
- matlab/matlab-agentic-toolkit · skills-catalog/matlab-software-development/matlab-run-tests · commit 2a7f215
- Licence
- BSD 2-Clause License (redistribution allowed)
- LICENSE (added by AutoGineer from LICENSE.md)
- ATTRIBUTION.md (written by AutoGineer)
- Synced
AutoGineer is not affiliated with or endorsed by MathWorks or MathWorks.
Download ZIP
The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download matlab-run-tests.zip