Skip to content

matlab/matlab-agentic-toolkit / skills-catalog/matlab-software-development/matlab-run-tests

matlab-run-tests

Verified

Run MATLAB test suites and analyze results, including test filtering, parallel execution, result diagnostics, code coverage collection, gap analysis, and CI/CD with buildtool. Use when running tests, filtering test suites, analyzing test failures, checking, collecting, or analyzing coverage, justifying uncovered code, or configuring CI pipelines. Do NOT use for writing, generating, or structuring tests. Do NOT use for Simulink coverage or Simulink testing workflows.

scripts/printCoverageGaps.m

View on GitHub
function printCoverageGaps(covResults)
%printCoverageGaps Print uncovered items from coverage results.
%
%   printCoverageGaps(covResults) prints uncovered items across all metric
%   levels present in covResults (CoverageResult output from CodeCoveragePlugin).
%
%   Tiers printed depend on the MetricLevel used during collection:
%     default (no MetricLevel) — statement & function only
%     "decision"               — through decision
%     "condition"              — through condition
%     "mcdc"                   — all

    arguments
        covResults matlab.coverage.Result
    end

    % --- statement & function (always available) ---
    for type = ["statement", "function"]
        [~, decs] = coverageSummary(covResults, type);
        items = decs.(type);
        uncov = items([items.ExecutionCount] == 0);
        for i = 1:numel(uncov)
            fprintf('Uncovered %s: %s:%d (%s)\n', type, uncov(i).Filename, ...
                uncov(i).SourceLocation.StartLine, uncov(i).FunctionName);
        end
    end

    % --- decision (MetricLevel "decision"+) ---
    [~, decs] = coverageSummary(covResults, "decision");
    for numFilesWithDecisions = 1:numel(decs)
        decisions = decs(numFilesWithDecisions).decision;
        for i = 1:numel(decisions)
            thisDecision = decisions(i);
            outcomes = [thisDecision.Outcome];
            for j = 1:numel(outcomes)
                if outcomes(j).ExecutionCount == 0
                    fprintf('Uncovered decision: %s:%d — %s → %s\n', ...
                        thisDecision.Filename, thisDecision.SourceLocation.StartLine, ...
                        thisDecision.Text, outcomes(j).Text);
                end
            end
        end
    end

    % --- condition (MetricLevel "condition"+) ---
    [~, decs] = coverageSummary(covResults, "condition");
    for numFilesWithConditions = 1:numel(decs)
        conditions = decs(numFilesWithConditions).condition;
        for i = 1:numel(conditions)
            cond = conditions(i);
            if cond.TrueCount == 0
                fprintf('Uncovered condition (true): %s:%d — %s\n', ...
                    cond.Filename, cond.SourceLocation.StartLine, cond.Text);
            end
            if cond.FalseCount == 0
                fprintf('Uncovered condition (false): %s:%d — %s\n', ...
                    cond.Filename, cond.SourceLocation.StartLine, cond.Text);
            end
        end
    end

    % --- mcdc (MetricLevel "mcdc") ---
    [~, decs] = coverageSummary(covResults, "mcdc");
    for i = 1:numel(decs)
        d = decs(i).mcdc;
        for j = 1:numel(d)
            conditions = d(j).Condition;
            for k = 1:numel(conditions)
                if ~conditions(k).Achieved
                    fprintf('Unachieved MC/DC: %s:%d — %s → %s\n', ...
                        d(j).Filename, d(j).SourceLocation.StartLine, ...
                        d(j).Text, conditions(k).Text);
                end
            end
        end
    end

end
% Copyright 2026 The MathWorks, Inc.
finishing-a-development-branchobra/superpowersUse when implementation is complete, all tests pass, and you need to decide how to integrate the workStars: 319kUpdated Claude CodeCodexVerifiedInstall
systematic-debuggingobra/superpowersUse when encountering any bug, test failure, or unexpected behavior, before proposing fixesStars: 319kUpdated Claude CodeCodexVerifiedInstall
test-driven-developmentobra/superpowersUse when implementing any feature or bugfix, before writing implementation codeStars: 319kUpdated Claude CodeCodexVerifiedInstall
skill-creatoranthropics/skillsCreate new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy.Stars: 197kUpdated Claude CodeCodexVerifiedInstall