Skip to content

matlab/agent-skills-playground / demos/requirements-based-verification/skills/simulink-test-sequence-from-ears

simulink-test-sequence-from-ears

Verified

Generate Simulink Test Sequence blocks and harnesses from EARS requirements. Use when asked to create a test case from a requirement, generate tests from a .slreqx file, or verify a Simulink model with requirement-based tests.

scripts/configureTestSequence.m

View on GitHub
function configureTestSequence(blockPath, reqId, pattern, trigger, behavior, signalMapping)
%CONFIGURETESTSEQUENCE Populate a Test Sequence block based on the EARS pattern
%
%   Dispatches to the appropriate pattern-specific configurator.
%
%   Inputs:
%     blockPath     - Simulink path to the Test Sequence block
%     reqId         - Requirement ID string
%     pattern       - EARS pattern string (see parseEARSPattern)
%     trigger       - Trigger/condition text (used in step comments)
%     behavior      - Expected behavior text (used in step comments)
%     signalMapping - Struct with fields .init, .stimulus, .verify

    stepPrefix = ['REQ' regexprep(reqId, '\W', '_')];

    sltest.testsequence.addSymbol(blockPath, 'testComplete', 'Data', 'Local');

    switch pattern
        case 'Event-Driven'
            configureEventDriven(blockPath, stepPrefix, trigger, behavior, reqId, signalMapping);

        case 'State-Driven'
            configureStateDriven(blockPath, stepPrefix, trigger, behavior, reqId, signalMapping);

        case 'Unwanted Behavior'
            configureUnwantedBehavior(blockPath, stepPrefix, trigger, behavior, reqId, signalMapping);

        case 'Ubiquitous'
            configureUbiquitous(blockPath, stepPrefix, behavior, reqId, signalMapping);

        case 'Optional'
            % Optional behaves like Event-Driven: enable the feature, then verify
            configureEventDriven(blockPath, stepPrefix, trigger, behavior, reqId, signalMapping);

        otherwise
            warning('configureTestSequence: unknown EARS pattern "%s" for REQ-%s', pattern, reqId);
    end
end
finishing-a-development-branchobra/superpowersUse when implementation is complete, all tests pass, and you need to decide how to integrate the workStars: 322kUpdated Claude CodeCodexVerifiedInstall
systematic-debuggingobra/superpowersUse when encountering any bug, test failure, or unexpected behavior, before proposing fixesStars: 322kUpdated Claude CodeCodexVerifiedInstall
test-driven-developmentobra/superpowersUse when implementing any feature or bugfix, before writing implementation codeStars: 322kUpdated 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: 198kUpdated Claude CodeCodexVerifiedInstall