testsuite — Discover MATLAB-style test procedures without running their bodies.
testsuite freezes selected source files, asks Core for semantic test discovery, and returns a scalar matlab.unittest.TestSuite-compatible object or a homogeneous object row. Discovery shares the same source and procedure identities as runtests and TestRunner.run; it does not execute test bodies.
Syntax
suite = testsuite
suite = testsuite(tests, Name, Value, ...)Inputs
tests- Type
Any- Required
- No
- Default
current folder- Description
- Test file, folder, function name, string array, or cell array of targets to discover without execution.
Name,Value- Type
Any- Required
- Variadic
- Default
- —
- Description
- Common options such as IncludeSubfolders, BaseFolder, Name, ProcedureName, and UseParallel.
Returns
suite- Type
Any- Description
- Scalar TestSuite object or homogeneous TestSuite object row; no test procedure is executed.
Errors
RunMat:Testing:RequiresExecutor- When
- `testsuite` is dispatched outside an active Core test executor.
- Message
testsuite: requires an active Core test executor
RunMat:testsuite:InvalidInput- When
- A target or option value has an unsupported type or value.
- Message
testsuite: invalid input
RunMat:testsuite:UnsupportedOption- When
- A documented option requires an execution mode not available through the in-program adapter.
- Message
testsuite: unsupported option
Targets and selection
suite = testsuite discovers the current folder. testsuite(target, Name, Value, ...) accepts a test file, folder, bare function name, string array, or cell of scalar text. BaseFolder constrains relative explicit targets, or supplies discovery roots when no target is given.
Folder discovery recognizes .m stems beginning with test or ending with Test, case-insensitively. IncludeSubfolders=true recursively searches subfolders. Explicit test paths need not match that naming convention.
Core discovers script, function, functiontests(localfunctions), and class suites semantically. Name and ProcedureName are substring filters on semantic display names, not the full MATLAB selector model. Runtime does not scan function declarations or append calls to source.
The returned objects include Name and TestFile metadata and can be supplied to the existing TestRunner service. Discovery itself neither executes qualifications nor mutates the caller workspace.
Controls and limitations
Host string scalars, character rows, and text collections control discovery. Exact integer, double, and logical flags accept only scalar zero or one. Resident controls reject without a GPU gather or provider lookup.
UseParallel=false is accepted; true is unsupported by the in-program adapter. Nonempty Tag filters remain unsupported at this entry point. OutputDetail and LoggingLevel accept scalar text but do not alter discovery output. The RunMat Coverage flag is accepted by the shared parser but does not collect coverage during discovery.
An active Core test service is required. It is selected from the explicitly retained RuntimeContext; no unrelated active session or alternate executor is substituted. Core constructs its existing child session and freezes the exact once-read source bytes.
Directory discovery, frozen sources, semantic descriptors, and result objects have no certified physical allocation bound. A finite host-memory policy rejects before filesystem discovery or reads; this entry does not claim bounded-host completion.
Zero or one output is supported. Invalid controls, discovery failures, missing executor, or unsupported infrastructure are diagnostics; discovering an invalid test body is distinct from executing a failed test.
This adapter does not implement MATLAB wildcard selectors, direct file/procedure selectors, namespace/project selector semantics, or advanced parameter/dependency filters. BaseFolder supplies path-resolution roots here rather than MATLAB's wildcard base-folder filter. Unknown options fail instead of being silently accepted.
Examples
Discover a script without executing its body
suite = testsuite('testDiscovery.m');Select a semantic test procedure by name
suite = testsuite('selectionTests.m', 'Name', 'testBeta');Using testsuite with coding agents
Open a RunMat example with live inputs, then ask the agent to explain how testsuite changes the result.
Run a small testsuite example, explain the result, then change one input and compare the output.
FAQ
Does testsuite run the test bodies?⌄
No. It returns semantic test procedure descriptors. Use runtests or a TestRunner to execute them.
Does discovery read and then regenerate source?⌄
No. Runtime reads each selected source once. Core freezes those original bytes and discovers semantic procedures without generated source calls.
Related Testing functions
Testing
functiontests · matlab.unittest.TestCase · matlab.unittest.TestRunner.addPlugin · matlab.unittest.TestRunner.run · matlab.unittest.TestRunner.withTextOutput
Constraints
matlab.unittest.constraints.IsEqualTo · matlab.unittest.constraints.IsFalse · matlab.unittest.constraints.IsTrue
Fixtures
matlab.unittest.fixtures.PathFixture · matlab.unittest.fixtures.TemporaryFolderFixture · matlab.unittest.TestCase.addTeardown · matlab.unittest.TestCase.applyFixture
Plugins
matlab.unittest.plugins.CodeCoveragePlugin.forFolder · matlab.unittest.plugins.TestRunnerPlugin
Qualifications
matlab.unittest.TestCase.assertEqual · matlab.unittest.TestCase.assertThat · matlab.unittest.TestCase.assertTrue · matlab.unittest.TestCase.assumeEqual · matlab.unittest.TestCase.assumeTrue · matlab.unittest.TestCase.fatalAssertTrue · matlab.unittest.TestCase.verifyEmpty · matlab.unittest.TestCase.verifyEqual · matlab.unittest.TestCase.verifyFalse · matlab.unittest.TestCase.verifyGreaterThan · matlab.unittest.TestCase.verifyLessThan · matlab.unittest.TestCase.verifyNotEmpty · matlab.unittest.TestCase.verifyNotEqual · matlab.unittest.TestCase.verifyThat · matlab.unittest.TestCase.verifyTrue
Source you can read
Every RunMat function's source is public. Read exactly how testsuite is executed, line by line, in Rust.
- View the source for testsuite in Rust on GitHub
- Learn how the RunMat runtime works
- Found a bug? Open an issue with a minimal reproduction.
About RunMat
RunMat is a runtime that executes MATLAB-syntax code fast on any GPU. The runtime is free for individuals, including freelancers; students and faculty at an academic institution, for teaching or research there; contributors to an open-source project, for work on that project; organizations with 250 or fewer people and US$10M or less in annual revenue; and anyone, for non-production use. See runmat.com/license.
- RunMat automatically optimizes your math for GPU execution on Apple, Nvidia, and AMD hardware. No code changes needed. Simulations that took hours now take minutes.
- Start running code in seconds. RunMat runs in the browser, on the desktop, or from the CLI. No license server, no IT ticket.