{"id":"7ebe6484-edb1-421b-a898-f6a24ff96ebe","shortId":"FGQc6R","kind":"skill","title":"matlab-test-creator","tagline":"Create comprehensive MATLAB unit tests using the MATLAB Testing Framework. Use when generating test files, test cases, unit tests, or when the user requests testing for MATLAB code, functions, or classes.","description":"# MATLAB Test Generator\n\nGenerate robust unit tests using the MATLAB Testing Framework. This skill covers:\n\n- **Test Creation**: Writing test classes, methods, fixtures, assertions, and mocks\n\n## Must-Follow Rules\n\n- **Present a test plan if needed** - Create a user-approved test plan before writing test code unless the scope is limited and straightforward.\n- **Show diff before updating** - For existing test files, always show the user a diff and wait for approval before editing.\n- **Always use class-based tests** - Every test file must define a class inheriting from `matlab.unittest.TestCase`. Never use function-based or script-based tests.\n- **Do not guess requirements** - If scope or expected behaviors are unclear, **ask**\n\n---\n\n# Test Creation\n\n## Test Class Template\n\nAdd properties, `TestParameter`, and setup/teardown blocks as needed.\n\n```matlab\nclassdef MyFunctionTest < matlab.unittest.TestCase\n\n    methods (Test)\n        % Individual test methods\n    end\nend\n```\n\n## Critical Rules\n\n### File Naming\n- Test files MUST end with `Test.m` (e.g., `myFunctionTest.m`)\n- Class name must match filename\n\n### Test Method Naming\n- Descriptive camelCase names starting with lowercase\n- Example: `testAdditionWithPositiveNumbers`\n\n### Test location\nIdeally, add all test files to a `tests/` folder alongside the source\n\n### Properties\nUse Mixed case unless it's a TestParameter. For a TestParameter, use camelCase. Only use properties if local variables won't suffice.\n\n### Assertions / Qualifications\n- Prefer `verify*` methods (continue on failure) over `assert*` (stop on failure)\n- Use `verifyError(@() func(args), \"errorID\")` for error testing\n- Use `verifyWarningFree(@() func(args))` for clean execution\n- Prefer informal APIs over `verifyThat` calls\n- **Floating-point comparisons should use tolerance:**\n  ```matlab\n  testCase.verifyEqual(actual, expected, AbsTol=1e-10);\n  testCase.verifyEqual(actual, expected, RelTol=1e-6);\n  ```\n- For advanced verification, constraint objects, and custom constraints see [references/constraints.md](references/constraints.md)\n\n### No Logic in Tests\n- **No `if`, `switch`, `for`, or `try/catch` in test methods.** If a test needs conditionals, split into separate methods.\n- Follow the **Arrange-Act-Assert** pattern: set up inputs, call the code under test, verify the result. Nothing else.\n\n### Using TestParameter\nParameterize only when **assertion logic is identical** across all cases — only the data varies. Use separate test methods when cases need different assertions, tolerances, setup, or when you'd need conditionals to distinguish them.\n\n### Test Scope\n- **Test public interfaces, not implementation.** Never test private methods directly — verify correctness through the public API.\n- If a private method seems complex enough to need its own tests, the user should refactor it into a separate, publicly testable function.\n\n### Determinism\nFor tests involving randomness, seed the RNG and restore it:\n```matlab\nmethods (TestMethodSetup)\n    function resetRandomSeed(testCase)\n        originalRng = rng;\n        testCase.addTeardown(@() rng(originalRng));\n        rng(42, \"twister\");\n    end\nend\n```\n\n### Test Assumptions\nMost tests do not need assumptions. Only add `assume*` when a test absolutely requires specific environment prerequisites that may not be present on all machines:\n```matlab\ntestCase.assumeTrue(canUseGPU(), \"Requires GPU\");\n```\n\n### Test Tagging\nUse `TestTags` attribute (e.g., `'Unit'`, `'Integration'`, `'Slow'`, `'GPU'`) on `methods (Test)` blocks for selective execution.\n\n### Test independence\nEach test should be able to run independently and be compatible with running tests in parallel.\n\n### Adding path to source files\nUse PathFixture to add paths so the tests have access to the source if needed. Use `IncludingSubfolders` when there are nested packages or subdirectories that also need to be on the path:\n\n```matlab\nmethods (TestClassSetup)\n    function addSourceToPath(testCase)\n        srcFolder = fullfile(fileparts(fileparts(mfilename('fullpath'))), 'src');\n        testCase.applyFixture(matlab.unittest.fixtures.PathFixture(srcFolder, ...\n            IncludingSubfolders=true));\n    end\nend\n```\n\nFor more details, if necessary, see [references/fixtures.md](references/fixtures.md).\n\n### Diagnostics\nAdd additional diagnostics for clarity where the framework diagnostic may be insufficient.\n\n# Test Planning\n\n**Assess complexity first, then follow the appropriate path.**\n\n### Simple tests (source code provided, clear behavior, no mocks/fixtures/parameterization)\n\n1. Briefly state what you'll test (methods + key edge cases)\n2. Write the test file after user confirms\n\n### Standard tests (Large codebase, multiple comprehensive test files) — 3-phase workflow: Gather → Plan → Implement\n\n## Phase 1: Gather Requirements\n\n### Checklist: Information needed (ask if unknown)\n\n- [ ] **Code to test** - Provide path or content of the function/class to test\n- [ ] **Expected behaviors** - What should the code do in normal cases?\n- [ ] **Error conditions** - What inputs should cause errors/warnings?\n- [ ] **Test scope**: Unit (isolated), Integration (with dependencies), or System?\n- [ ] **External dependencies**: Files, databases, network, hardware?\n- [ ] **Determinism needs**: Random numbers, timestamps, or other non-deterministic behavior?\n- [ ] **Deployment targets**: MATLAB Coder or Compiler SDK? If yes, recommend equivalence testing via `matlabtest.coder.TestCase` / `matlabtest.compiler.TestCase`.\n\n## Phase 2: Present Test Plan for Approval\n\nPresent a test plan. Do NOT write any test files until the user confirms the plan. A plan may include: list of test methods with names, which behaviors each covers, parameterization strategy, fixtures needed, and edge cases selected\n\n### Edge Cases to Consider\n\n- Empty inputs (`[]`, `''`, `{}`)\n- Boundary values (0, 1, -1, max, min)\n- Invalid types (string instead of number, etc.)\n- Large inputs (performance/memory)\n- Special values (NaN, Inf, -Inf)\n\n## Phase 3: Implement Approved Plan\n\nApply reference card patterns. Write new test files or show diffs for existing files (per Must-Follow Rules).\n\n# References\n\nIn many cases, what's present in this file should be sufficient. Do not read the references cards unless the conditions stated in the table are met.\n\n| Load when code under test... | Card |\n|---|---|\n| Uses setup/teardown, temp files, figures, database connections, shared state, or needs built-in fixtures | [references/fixtures.md](references/fixtures.md) |\n| Involves floating-point math needing tolerance selection, constraint objects (`verifyThat`), or custom constraints | [references/constraints.md](references/constraints.md) |\n| Needs multiple `TestParameter` properties, dynamic parameters (`TestParameterDefinition`), or help with cross-product pitfalls | [references/parameterized-tests.md](references/parameterized-tests.md) |\n| Depends on external services, needs mock objects, or requires dependency injection | [references/mocking.md](references/mocking.md) |","tags":["matlab","test","creator","skills","agent-skill","agent-skills","agentic-ai","agents","claude","claude-api","claude-code","claude-desktop"],"capabilities":["skill","source-matlab","skill-matlab-test-creator","topic-agent-skill","topic-agent-skills","topic-agentic-ai","topic-agents","topic-claude","topic-claude-api","topic-claude-code","topic-claude-desktop","topic-claude-skills","topic-matlab","topic-matlab-skills"],"categories":["skills"],"synonyms":[],"warnings":[],"endpointUrl":"https://skills.sh/matlab/skills/matlab-test-creator","protocol":"skill","transport":"skills-sh","auth":{"type":"none","details":{"cli":"npx skills add matlab/skills","source_repo":"https://github.com/matlab/skills","install_from":"skills.sh"}},"qualityScore":"0.482","qualityRationale":"deterministic score 0.48 from registry signals: · indexed on github topic:agent-skills · 65 github stars · SKILL.md body (7,048 chars)","verified":false,"liveness":"unknown","lastLivenessCheck":null,"agentReviews":{"count":0,"score_avg":null,"cost_usd_avg":null,"success_rate":null,"latency_p50_ms":null,"narrative_summary":null,"summary_updated_at":null},"enrichmentModel":"deterministic:skill-github:v1","enrichmentVersion":1,"enrichedAt":"2026-04-22T06:55:55.021Z","embedding":null,"createdAt":"2026-04-18T22:14:24.446Z","updatedAt":"2026-04-22T06:55:55.021Z","lastSeenAt":"2026-04-22T06:55:55.021Z","tsv":"'-1':777 '0':775 '1':609,643,776 '1e-10':282 '1e-6':287 '2':620,723 '3':636,796 '42':441 'abl':500 'absolut':459 'abstol':281 'access':526 'across':350 'act':325 'actual':279,284 'ad':512 'add':152,202,454,520,578 'addit':579 'addsourcetopath':553 'advanc':289 'alongsid':210 'also':542 'alway':97,109 'api':266,394 'appli':800 'appropri':598 'approv':75,106,728,798 'arg':252,260 'arrang':324 'arrange-act-assert':323 'ask':146,649 'assert':58,236,245,326,346,365 'assess':592 'assum':455 'assumpt':446,452 'attribut':481 'base':113,129,133 'behavior':143,606,665,706,756 'block':157,490 'boundari':773 'briefli':610 'built':865 'built-in':864 'call':269,331 'camelcas':192,226 'canusegpu':474 'card':802,837,852 'case':21,216,352,362,619,673,765,768,822 'caus':679 'checklist':646 'clariti':582 'class':35,55,112,121,150,183 'class-bas':111 'classdef':161 'clean':262 'clear':605 'code':32,81,333,603,652,669,849 'codebas':631 'coder':710 'comparison':273 'compat':506 'compil':712 'complex':400,593 'comprehens':6,633 'condit':316,373,675,840 'confirm':627,742 'connect':859 'consid':770 'constraint':291,295,878,883 'content':658 'continu':241 'correct':390 'cover':50,758 'creat':5,71 'creation':52,148 'creator':4 'critic':171 'cross':897 'cross-product':896 'custom':294,882 'd':371 'data':355 'databas':693,858 'defin':119 'depend':687,691,902,911 'deploy':707 'descript':191 'detail':571 'determin':418,696 'determinist':705 'diagnost':577,580,586 'diff':90,102,810 'differ':364 'direct':388 'distinguish':375 'dynam':890 'e.g':181,482 'edg':618,764,767 'edit':108 'els':340 'empti':771 'end':169,170,178,443,444,567,568 'enough':401 'environ':462 'equival':717 'error':255,674 'errorid':253 'errors/warnings':680 'etc':786 'everi':115 'exampl':197 'execut':263,493 'exist':94,812 'expect':142,280,285,664 'extern':690,904 'failur':243,248 'figur':857 'file':19,96,117,173,176,205,516,624,635,692,738,807,813,828,856 'filenam':187 'filepart':557,558 'first':594 'fixtur':57,761,867 'float':271,872 'floating-point':270,871 'folder':209 'follow':63,321,596,817 'framework':14,47,585 'fullfil':556 'fullpath':560 'func':251,259 'function':33,128,417,432,552 'function-bas':127 'function/class':661 'gather':639,644 'generat':17,38,39 'gpu':476,486 'guess':137 'hardwar':695 'help':894 'ideal':201 'ident':349 'implement':383,641,797 'includ':748 'includingsubfold':533,565 'independ':495,503 'individu':166 'inf':793,794 'inform':265,647 'inherit':122 'inject':912 'input':330,677,772,788 'instead':783 'insuffici':589 'integr':484,685 'interfac':381 'invalid':780 'involv':421,870 'isol':684 'key':617 'larg':630,787 'limit':86 'list':749 'll':614 'load':847 'local':231 'locat':200 'logic':300,347 'lowercas':196 'machin':471 'mani':821 'match':186 'math':874 'matlab':2,7,12,31,36,45,160,277,429,472,549,709 'matlab-test-cr':1 'matlab.unittest.fixtures.pathfixture':563 'matlab.unittest.testcase':124,163 'matlabtest.coder.testcase':720 'matlabtest.compiler.testcase':721 'max':778 'may':465,587,747 'met':846 'method':56,164,168,189,240,311,320,360,387,398,430,488,550,616,752 'mfilenam':559 'min':779 'mix':215 'mock':60,907 'mocks/fixtures/parameterization':608 'multipl':632,887 'must':62,118,177,185,816 'must-follow':61,815 'myfunctiontest':162 'myfunctiontest.m':182 'name':174,184,190,193,754 'nan':792 'necessari':573 'need':70,159,315,363,372,403,451,531,543,648,697,762,863,875,886,906 'nest':537 'network':694 'never':125,384 'new':805 'non':704 'non-determinist':703 'normal':672 'noth':339 'number':699,785 'object':292,879,908 'originalrng':435,439 'packag':538 'parallel':511 'paramet':891 'parameter':343,759 'path':513,521,548,599,656 'pathfixtur':518 'pattern':327,803 'per':814 'performance/memory':789 'phase':637,642,722,795 'pitfal':899 'plan':68,77,591,640,726,732,744,746,799 'point':272,873 'prefer':238,264 'prerequisit':463 'present':65,468,724,729,825 'privat':386,397 'product':898 'properti':153,213,229,889 'provid':604,655 'public':380,393,415 'qualif':237 'random':422,698 'read':834 'recommend':716 'refactor':410 'refer':801,819,836 'references/constraints.md':297,298,884,885 'references/fixtures.md':575,576,868,869 'references/mocking.md':913,914 'references/parameterized-tests.md':900,901 'reltol':286 'request':28 'requir':138,460,475,645,910 'resetrandomse':433 'restor':427 'result':338 'rng':425,436,438,440 'robust':40 'rule':64,172,818 'run':502,508 'scope':84,140,378,682 'script':132 'script-bas':131 'sdk':713 'see':296,574 'seed':423 'seem':399 'select':492,766,877 'separ':319,358,414 'servic':905 'set':328 'setup':367 'setup/teardown':156,854 'share':860 'show':89,98,809 'simpl':600 'skill':49 'skill-matlab-test-creator' 'slow':485 'sourc':212,515,529,602 'source-matlab' 'special':790 'specif':461 'split':317 'src':561 'srcfolder':555,564 'standard':628 'start':194 'state':611,841,861 'stop':246 'straightforward':88 'strategi':760 'string':782 'subdirectori':540 'suffic':235 'suffici':831 'switch':305 'system':689 'tabl':844 'tag':478 'target':708 'temp':855 'templat':151 'test':3,9,13,18,20,23,29,37,42,46,51,54,67,76,80,95,114,116,134,147,149,165,167,175,188,199,204,208,256,302,310,314,335,359,377,379,385,406,420,445,448,458,477,489,494,497,509,524,590,601,615,623,629,634,654,663,681,718,725,731,737,751,806,851 'test.m':180 'testabl':416 'testadditionwithpositivenumb':198 'testcas':434,554 'testcase.addteardown':437 'testcase.applyfixture':562 'testcase.assumetrue':473 'testcase.verifyequal':278,283 'testclasssetup':551 'testmethodsetup':431 'testparamet':154,221,224,342,888 'testparameterdefinit':892 'testtag':480 'timestamp':700 'toler':276,366,876 'topic-agent-skill' 'topic-agent-skills' 'topic-agentic-ai' 'topic-agents' 'topic-claude' 'topic-claude-api' 'topic-claude-code' 'topic-claude-desktop' 'topic-claude-skills' 'topic-matlab' 'topic-matlab-skills' 'true':566 'try/catch':308 'twister':442 'type':781 'unclear':145 'unit':8,22,41,483,683 'unknown':651 'unless':82,217,838 'updat':92 'use':10,15,43,110,126,214,225,228,249,257,275,341,357,479,517,532,853 'user':27,74,100,408,626,741 'user-approv':73 'valu':774,791 'vari':356 'variabl':232 'verif':290 'verifi':239,336,389 'verifyerror':250 'verifythat':268,880 'verifywarningfre':258 'via':719 'wait':104 'won':233 'workflow':638 'write':53,79,621,735,804 'yes':715","prices":[{"id":"3c6785d3-1c28-444d-9367-ea2549a32f47","listingId":"7ebe6484-edb1-421b-a898-f6a24ff96ebe","amountUsd":"0","unit":"free","nativeCurrency":null,"nativeAmount":null,"chain":null,"payTo":null,"paymentMethod":"skill-free","isPrimary":true,"details":{"org":"matlab","category":"skills","install_from":"skills.sh"},"createdAt":"2026-04-18T22:14:24.446Z"}],"sources":[{"listingId":"7ebe6484-edb1-421b-a898-f6a24ff96ebe","source":"github","sourceId":"matlab/skills/matlab-test-creator","sourceUrl":"https://github.com/matlab/skills/tree/main/skills/matlab-test-creator","isPrimary":false,"firstSeenAt":"2026-04-18T22:14:24.446Z","lastSeenAt":"2026-04-22T06:55:55.021Z"}],"details":{"listingId":"7ebe6484-edb1-421b-a898-f6a24ff96ebe","quickStartSnippet":null,"exampleRequest":null,"exampleResponse":null,"schema":null,"openapiUrl":null,"agentsTxtUrl":null,"citations":[],"useCases":[],"bestFor":[],"notFor":[],"kindDetails":{"org":"matlab","slug":"matlab-test-creator","github":{"repo":"matlab/skills","stars":65,"topics":["agent-skill","agent-skills","agentic-ai","agents","claude","claude-api","claude-code","claude-desktop","claude-skills","matlab","matlab-skills"],"license":"other","html_url":"https://github.com/matlab/skills","pushed_at":"2026-03-20T00:56:44Z","description":"A collection of Agent Skills for MATLAB development. Skills are specialized instruction sets that extend a coding agent's capabilities for specific tasks, automatically activating when needed.","skill_md_sha":"1653626c80e905087b2fff8ecd9535691ba8c30a","skill_md_path":"skills/matlab-test-creator/SKILL.md","default_branch":"main","skill_tree_url":"https://github.com/matlab/skills/tree/main/skills/matlab-test-creator"},"layout":"multi","source":"github","category":"skills","frontmatter":{"name":"matlab-test-creator","license":"MathWorks BSD-3-Clause (see LICENSE)","description":"Create comprehensive MATLAB unit tests using the MATLAB Testing Framework. Use when generating test files, test cases, unit tests, or when the user requests testing for MATLAB code, functions, or classes."},"skills_sh_url":"https://skills.sh/matlab/skills/matlab-test-creator"},"updatedAt":"2026-04-22T06:55:55.021Z"}}