In 2026, Atlas helps MATLAB developers add real unit tests to untested code by leveraging the `matlab.unittest (runtests)` framework and adhering to existing repository conventions. Atlas reads your module, identifies public functions, and then generates a `matlab.unittest.TestCase` subclass, ensuring comprehensive test coverage.
How Atlas Identifies Untested MATLAB Code for Unit Testing
In 2026, Atlas helps MATLAB developers identify untested code by searching with hybrid semantic and keyword retrieval. Atlas indexes `.m` function files and `classdef` blocks using AST declarations, ensuring no public function or method is overlooked for unit testing.
Atlas begins the unit testing workflow by using its `read` tool to ingest your MATLAB codebase. This includes all `.m` function files and `classdef` blocks. Following this, Atlas employs its `lsp` tool with the `documentSymbol` operation to enumerate all exported symbols within the target module. This process leverages Atlas's ability to index code by AST declarations using tree-sitter, rather than relying on blind line windows. By understanding the structural components of your MATLAB code, Atlas can precisely identify every public function, method, and property that requires unit test coverage. This ensures that when Atlas proceeds to generate tests, no public API surface is inadvertently missed, providing a thorough foundation for your `matlab.unittest.TestCase` subclasses.
Adopting Existing MATLAB Test Conventions with Atlas
Atlas ensures new MATLAB unit tests match existing repository conventions by using its `grep` tool to find and analyze current `matlab.unittest.TestCase` files. This process, critical in 2026, allows Atlas to replicate established naming, structure, and import styles.
A key aspect of integrating new unit tests into an existing MATLAB project is maintaining consistency with established conventions. Atlas addresses this by using its `grep` tool to search your repository for existing `matlab.unittest.TestCase` files. For instance, Atlas might search for files named `*Test.m` or containing `classdef (Test)` to identify your current testing framework. By analyzing these files, Atlas learns your repository's preferred naming conventions, such as `MyFunctionTest.m` for a test class, the structure of your `matlab.unittest.TestCase` subclasses, and any specific import styles or setup/teardown methods. This capability ensures that any new test files generated by Atlas, for example, `tests/NewModuleTest.m`, direct integrate into your project's existing testing ecosystem without introducing stylistic inconsistencies.
Generating and Reviewing New MATLAB Unit Tests with Atlas
Atlas drafts new `matlab.unittest.TestCase` subclasses using its `write` tool, presenting a unified diff for approval before any changes land on disk. This permission-gated process, a core Atlas feature in 2026, ensures transparency and developer control over generated MATLAB tests.
Once Atlas has identified the untested MATLAB code and understood the repository's test conventions, it proceeds to draft the new unit test files. Using its `write` tool, Atlas generates a `matlab.unittest.TestCase` subclass, populating it with test methods corresponding to the identified public functions and methods. For example, it might create `tests/MyNewFeatureTest.m`. Crucially, before any changes are written to disk, Atlas computes a unified diff for every file edit and surfaces it for your approval. This permission-gated prompt allows you to review the exact changes Atlas proposes, ensuring full transparency and control. For large MATLAB modules with many functions, Atlas can also utilize its `todowrite` tool to manage progress, breaking down the test generation into smaller, more manageable tasks, which helps maintain focus and iterative development.
Executing and Iterating on MATLAB Unit Tests with Atlas
Atlas executes new MATLAB unit tests using its `bash` tool to run `matlab.unittest (runtests)`, providing immediate feedback on test failures. Output exceeding 2000 lines or 50 KB is truncated, with full logs saved, enabling efficient iteration in 2026.
The true value of a test lies in its execution. Atlas facilitates this by using its `bash` tool to run the newly generated MATLAB unit tests. For instance, Atlas will execute a command like `runtests('tests/MyNewFeatureTest.m')` to invoke the `matlab.unittest` framework. Atlas captures the output from `runtests`, providing immediate feedback on any failing assertions. If the output exceeds 2000 lines or 50 KB, it is truncated in the terminal, but the full log is saved to a file that you can easily access for detailed analysis. This allows for efficient debugging and iteration. You can then use Atlas's `edit` tool to modify the test class or the module under test, repeating the `bash` execution until the test suite is green. Atlas can also apply `MATLAB Format Code` conventions to the touched files before you approve them, ensuring style consistency.
Ensuring Safety and Transparency in MATLAB Test Generation with Atlas
Atlas prioritizes safety and transparency in MATLAB test generation through permission-gated tool calls and a read-only plan agent. Every file edit, including new `matlab.unittest.TestCase` files, generates a unified diff for explicit approval, a key feature in 2026.
Developer trust and control are paramount when using AI coding agents. Atlas is designed with multiple layers of safety and transparency for MATLAB development in 2026. Every Atlas tool call, whether it's `read`, `grep`, `write`, or `bash`, is permission-gated against allow, ask, and deny rules before it runs. Atlas first drafts a plan in a read-only plan agent, asking for your approval before switching to a build agent that can make changes. When Atlas proposes to write a new `matlab.unittest.TestCase` subclass or modify an existing `.m` file, it computes a unified diff for every file edit and surfaces it for your explicit approval. This ensures you always know exactly what changes are being made to your MATLAB codebase. Furthermore, Atlas reads git branches, status, and diffs, and can snapshot file changes as git patches, allowing edits to be easily diffed and rolled back if needed.
Step by step
- 01Read the MATLAB module: Use `atlas read` to ingest your `.m` function files or `classdef` blocks, allowing Atlas to understand your codebase.
- 02Enumerate public symbols: Use `atlas lsp documentSymbol` to list all exported functions and methods in the target MATLAB module, ensuring no public API is missed for testing.
- 03Identify existing test conventions: Use `atlas grep` to locate an existing `matlab.unittest.TestCase` file in your repository, such as `tests/MyExistingFunctionTest.m`, to understand the established naming and structure.
- 04Draft the new MATLAB test class: Use `atlas write` to generate a new `matlab.unittest.TestCase` subclass, for example, `tests/MyNewModuleTest.m`, based on the enumerated symbols and copied conventions. Review the unified diff presented by Atlas.
- 05Run the MATLAB unit tests: Execute the newly drafted tests using `atlas bash "runtests('tests/MyNewModuleTest.m')"` to verify functionality and identify any failures.
- 06Iterate and refine tests: Use `atlas edit` to modify the test class based on `runtests` output, and apply `MATLAB Format Code` conventions to touched files before approving changes.
- 07Commit changes: Use `atlas git commit` to stage and commit the new test files once they are green and approved, integrating them into your version control.
Frequently asked questions
- How does Atlas find existing MATLAB test files to copy conventions?
- Atlas uses its `grep` tool to search your repository for files matching patterns like `*Test.m` or `matlab.unittest.TestCase` subclasses, allowing it to identify and replicate your established testing framework and naming conventions.
- Can Atlas run `matlab.unittest (runtests)` directly?
- Yes, Atlas uses its `bash` tool to execute `runtests` commands, such as `runtests('myModuleTests')`, behind a permission prompt. It captures the output, truncating large logs but saving the full details to a file.
- What if my MATLAB module is very large and has many functions?
- For large MATLAB modules, Atlas can use its `todowrite` tool to manage progress, breaking down the test generation into smaller, manageable tasks. This helps ensure comprehensive coverage without overwhelming the developer.
- How does Atlas ensure the new MATLAB tests match my team's coding style?
- Atlas can apply `MATLAB Format Code` conventions to any touched files before you approve them, ensuring that new `matlab.unittest.TestCase` subclasses adhere to your repository's established formatting guidelines.
- Is my MATLAB code sent to third-party servers when using Atlas?
- No, Atlas can build its code index with local Ollama embeddings, keeping your MATLAB code off third-party servers. All tool calls are permission-gated, and file edits are presented as diffs for local approval.
- How does Atlas handle `classdef` blocks and object-oriented MATLAB code?
- Atlas indexes code by AST declarations using tree-sitter, allowing it to understand `classdef` blocks, function signatures, and methods within your MATLAB object-oriented code. This enables it to generate appropriate `matlab.unittest.TestCase` subclasses for class methods.
- Can Atlas help refactor existing MATLAB tests?
- While this page focuses on adding new tests, Atlas's `read`, `lsp`, `edit`, and `bash` tools can be used to analyze, modify, and re-run existing `matlab.unittest` test files, supporting refactoring efforts with its diff-based approval process.
Try Atlas in your terminal
The terminal-native AI coding agent. Free core, single binary.
Install AtlasRelated guides
Write Unit Tests for Untested Code with Atlas in 2026
How to write unit tests for untested code with Atlas in 2026: the lsp tool enumerates exported symbols, grep copies repo conventions, and bash actually runs the suite.
Self-review your working diff before committing in MATLAB with Atlas in 2026
Catch your own mistakes in uncommitted MATLAB code diffs before they reach review or CI. Atlas helps MATLAB developers in 2026 self-review changes, run `matlab.unittest (runtests)`, and apply `MATLAB Format Code` for
Plan a Multi-File Change Before Editing in MATLAB with Atlas in 2026
Design complex, multi-file MATLAB changes and get them reviewed before modifying a single line of code using Atlas's dedicated plan agent and integrated toolchain.
Migrate a deprecated API across every callsite in MATLAB with Atlas in 2026
Streamline deprecated API migrations in MATLAB codebases with Atlas in 2026. Automate finding all callers, applying patches, and verifying with `matlab.unittest (runtests)` for a complete, safe transition.
Review a Pull Request in MATLAB with Atlas in 2026
Atlas helps MATLAB developers in 2026 review pull requests by providing full code context, checking function references, and running matlab.unittest (runtests) for comprehensive bug detection.
Upgrade a dependency and fix the breakage in MATLAB with Atlas in 2026
In 2026, Atlas helps MATLAB developers upgrade dependencies and fix breaking changes. Automate MATLAB Add-On Manager (mpm) updates, repair compile errors, and resolve matlab.unittest failures with AI-driven precision.
Run Atlas Headless in CI for MATLAB Projects in 2026
Automate Atlas in your MATLAB CI/CD pipelines. Get machine-readable output, pre-approve tools, and integrate with matlab.unittest and MATLAB Format Code for efficient, non-interactive code generation and review.
Audit a repo with parallel subagents in MATLAB with Atlas in 2026
Sweep your MATLAB repository for issues without context window limits. Atlas uses parallel subagents to audit .m files, classdef blocks, and matlab.unittest test classes efficiently.