In 2026, Erlang developers can efficiently add unit tests to untested modules using Atlas, which integrates directly with the `rebar3` build tool and `rebar3 eunit` test runner to ensure new tests adhere to existing repository conventions and pass successfully. Atlas reads the target Erlang module, identifies its exported functions, and then generates a new test file that mirrors the project's established testing style, all before running `rebar3 eunit` to validate the new suite.
How Atlas Identifies Untested Erlang Functions and Existing Conventions
Atlas begins the testing workflow by thoroughly understanding the target Erlang module and its surrounding codebase, a process that takes mere seconds in 2026. It uses the `read` tool to ingest the module's source code and the `lsp` tool's `documentSymbol` operation to enumerate all exported functions.
To write effective unit tests for an untested Erlang module, Atlas first needs to know what functions are publicly accessible and thus require testing. It accomplishes this by using the `read` tool to load the `src/my_module.erl` file into its context. Following this, Atlas employs the `lsp` tool with the `documentSymbol` operation on that specific Erlang file. This operation leverages the Language Server Protocol to provide a precise list of all exported symbols, ensuring that no public function within the Erlang module is overlooked during test generation. This detailed understanding of the module's API is crucial for comprehensive test coverage. Beyond understanding the module itself, Atlas also learns the existing testing conventions of the Erlang repository. It uses the `grep` tool to search for an existing test file, typically within the `test/` directory, to identify the project's preferred testing framework, import style, and naming conventions. For instance, Atlas might `grep` for `eunit_test` or `-module` declarations in existing test files to infer how `rebar3 eunit` suites are structured. This step is vital because Atlas's core capability is to match the repository's established patterns rather than introducing new, potentially inconsistent, styles. This ensures that any new `test/my_module_tests.erl` file direct integrates with the existing Erlang codebase.
How Atlas Writes New Erlang Unit Test Files
After analyzing the target Erlang module and existing test conventions, Atlas drafts the new unit test file, typically named `test/my_module_tests.erl`, using its `write` tool. This process, refined by 2026, ensures the generated code adheres to the project's `rebar3 eunit` structure.
Once Atlas has a clear understanding of the Erlang module's exported functions and the repository's established testing patterns, it proceeds to write the new unit test file. The `write` tool is central to this step. Atlas generates the content for a new file, such as `test/my_module_tests.erl`, populating it with test cases for each identified exported function. The structure of these test cases, including the use of `eunit` assertions and module attributes like `-module(my_module_tests).` and `-include_lib("eunit/include/eunit.hrl").`, directly reflects the conventions learned during the `grep` phase. Before any changes are committed to disk, Atlas presents a unified diff of the proposed `test/my_module_tests.erl` file. This diff is surfaced in the permission prompt, allowing the Erlang developer to review every line of the generated code. This transparency ensures that the developer maintains full control over the codebase and can approve or reject the changes. If the initial draft requires adjustments, the developer can provide feedback, and Atlas will iterate on the test file, ensuring the generated tests are accurate, comprehensive, and align with the developer's expectations for the Erlang module.
Running and Iterating on Erlang Unit Tests with Atlas
The true validation of any new Erlang unit test suite comes from execution, a step Atlas facilitates using its `bash` tool to invoke `rebar3 eunit`. In 2026, this iterative process ensures that all new tests pass and the module is thoroughly covered.
Writing a test file is only half the battle; the tests must actually run and pass. Atlas uses its `bash` tool to execute the Erlang test runner, `rebar3 eunit`. The command `atlas bash "rebar3 eunit"` is issued, and Atlas captures the output, including any failures or errors. This direct execution within the terminal-native environment provides immediate feedback on the efficacy of the newly written tests. If `rebar3 eunit` reports failures, Atlas enters an iterative loop. It uses the `edit` tool to allow the developer to modify the `test/my_module_tests.erl` file or even the `src/my_module.erl` itself, based on the test results. For large Erlang modules or complex test suites, Atlas can maintain a `todowrite` list to track progress and ensure all identified issues are addressed. After edits, Atlas will again run `atlas bash "rebar3 eunit"` to re-validate the suite. This cycle of editing and running continues until all tests pass, indicating that the new unit tests are correct and the `src/my_module.erl` functions behave as expected. Atlas also handles large outputs from `rebar3 eunit`; if the output exceeds 2000 lines or 50 KB, it truncates the display but saves the full log to a file for detailed review.
Ensuring Erlang Code Quality and Safety with Atlas
Atlas incorporates multiple safety and quality checks throughout the testing workflow, ensuring that all changes to Erlang code are reviewed and adhere to project standards. By 2026, these mechanisms are integral to maintaining robust Erlang/OTP systems.
Maintaining code quality and ensuring safety are paramount when modifying an Erlang codebase. Atlas integrates several features to provide a secure and controlled development experience. Every tool call made by Atlas, including `write` and `bash`, is permission-gated. This means that before Atlas executes a command that could alter files or run system commands, it presents a prompt for explicit approval. For instance, before `atlas bash "rebar3 eunit"` runs, you will be asked to confirm. Furthermore, Atlas computes a unified diff for every file edit it proposes, such as changes to `test/my_module_tests.erl` or `src/my_module.erl`. This diff is surfaced for approval, giving the Erlang developer a clear, line-by-line view of what Atlas intends to change. This granular control prevents unintended modifications. After the tests are green, Atlas can also run `erlfmt` on the touched modules, ensuring that the new test files and any modified source files conform to the project's established Erlang formatting style. This ensures the diff matches project style and avoids introducing formatting inconsistencies. Finally, Atlas reads git branches, status, and diffs, and can stage and create commits on your behalf, providing a complete and auditable workflow for integrating new Erlang unit tests.
Step by step
- 011: Use `atlas read` to load the target Erlang module, for example: `atlas read src/my_module.erl`.
- 022: Employ `atlas lsp documentSymbol` on the module to enumerate all exported functions: `atlas lsp documentSymbol src/my_module.erl`.
- 033: Use `atlas grep` to find an existing Erlang test file and learn the project's `rebar3 eunit` conventions: `atlas grep "eunit_test" test/`.
- 044: Draft the new Erlang unit test file, like `test/my_module_tests.erl`, using `atlas write`. Review the presented diff for accuracy and approve the changes.
- 055: Run the newly created Erlang test suite with `rebar3 eunit` via `atlas bash`: `atlas bash "rebar3 eunit"`.
- 066: If `rebar3 eunit` reports failures, use `atlas edit` to modify `test/my_module_tests.erl` or `src/my_module.erl` to fix issues. For large modules, track progress with `todowrite`.
- 077: Repeat step 5 and 6 until all `rebar3 eunit` tests pass successfully.
- 088: Ensure Erlang code style consistency by running `erlfmt` on the touched files using `atlas bash`: `atlas bash "erlfmt test/my_module_tests.erl src/my_module.erl"`.
- 099: Approve the final changes and let Atlas stage and create a git commit for the new Erlang unit tests.
Frequently asked questions
- How does Atlas identify which functions in an Erlang module need testing?
- Atlas uses the `lsp` tool's `documentSymbol` operation on the target Erlang module, such as `src/my_module.erl`, to accurately enumerate all its exported functions. This ensures that every public function is considered for unit test coverage.
- Can Atlas ensure new Erlang tests match my project's existing `rebar3 eunit` style?
- Yes, Atlas is designed to match existing conventions. It uses the `grep` tool to analyze existing Erlang test files in your `test/` directory, learning the preferred `rebar3 eunit` framework, import style, and naming conventions before generating new tests.
- What happens if the `rebar3 eunit` output is very long when run by Atlas?
- If the output from `rebar3 eunit` exceeds 2000 lines or 50 KB, Atlas truncates the displayed output in the terminal. However, the full log is always saved to a file, which you can then review in detail to diagnose any Erlang test failures.
- How does Atlas handle code formatting for new Erlang test files?
- Atlas integrates with `erlfmt`, the standard Erlang formatter. After tests are passing, Atlas can run `atlas bash "erlfmt test/my_module_tests.erl"` to automatically format the new test file, ensuring it adheres to your project's established style guidelines.
- Is my Erlang source code sent to third-party servers when using Atlas?
- No, Atlas prioritizes local privacy. It can build its code index with local Ollama embeddings, meaning your Erlang source code remains on your machine and is not sent to third-party servers for processing or indexing.
- How does Atlas prevent unwanted changes to my Erlang application's code?
- Atlas employs robust safety mechanisms. Every tool call that modifies files or executes commands is permission-gated, requiring your explicit approval. Additionally, Atlas computes and displays a unified diff for every proposed change to your Erlang files, allowing you to review and approve each edit before it's written to disk.
- Can Atlas help with `rebar3 ct` for Common Test suites, or is it only for `eunit`?
- While this page focuses on `rebar3 eunit` for unit tests, Atlas is capable of assisting with `rebar3 ct` for Common Test suites as well. You can ask Atlas to add a Common Test suite under `test/`, and it will leverage its tools to generate and run those tests, behind a permission prompt.
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.
Atlas for Erlang in 2026
Atlas is a terminal-native AI coding agent for Erlang/OTP in 2026. Run it in an app with a rebar.config, map supervisors and gen_server modules, review every diff.
Self-review Your Working Diff Before Committing in Erlang with Atlas in 2026
Erlang developers in 2026 use Atlas to self-review uncommitted diffs, catching mistakes before CI. Leverage rebar3, erlfmt, and eunit with AI assistance.
Plan a Multi-File Change Before Editing in Erlang with Atlas in 2026
In 2026, Erlang developers use Atlas to plan and review complex multi-file changes, ensuring design approval before modifying a single line of code or running rebar3. Securely design Erlang system updates.
Locate Erlang Behavior Implementations with Atlas in 2026
In 2026, Erlang developers use Atlas to quickly find where a behavior is implemented, leveraging semantic search, grep, and LSP tools across rebar3 projects.
Add a Regression Test for a Bug Fix in Erlang with Atlas in 2026
Lock in Erlang bug fixes with Atlas in 2026. Learn to write failing regression tests using rebar3 eunit, apply fixes, and confirm passes, all with Atlas's terminal-native AI agent.
Automate GitHub Issue and Pull Request Triage in Erlang with Atlas in 2026
Automate GitHub issue and pull request triage for Erlang projects using Atlas. Integrate with rebar3 and erlfmt, ensuring safe, permission-gated responses from trusted users in your CI/CD pipeline.
Refactor a Legacy Erlang Module with Atlas in 2026
Safely refactor Erlang modules in 2026 using Atlas, the terminal-native AI coding agent. Map callsites, verify behavior with rebar3 eunit, and apply changes with precision, all while maintaining Erlang code style with