In 2026, Fortran developers can efficiently add real unit tests to untested modules using Atlas, which integrates directly with the `fpm` package manager and `fpm test (test-drive)` runner. Atlas helps you adopt existing repository conventions for test structure and style, ensuring new tests fit direct into your project and are validated by actual execution.
How Atlas identifies Fortran module interfaces for testing
Atlas streamlines the process of writing unit tests for Fortran code, starting in 2026, by understanding your existing codebase and test conventions. It uses its `read` and `lsp` tools to analyze module interfaces, ensuring comprehensive test coverage for public symbols and functions within your Fortran project.
To begin writing unit tests for an untested Fortran module, Atlas first needs to understand its structure and exposed functionality. Atlas employs its `read` tool to ingest the target Fortran source file, such as `src/my_module.f90`. Following this, it utilizes the `lsp` tool with the `documentSymbol` operation to enumerate all exported symbols, including subroutines, functions, and variables declared within the module. This meticulous approach ensures that no public interface is overlooked, allowing Atlas to generate a comprehensive test plan that covers every accessible part of your Fortran code, from legacy FIXED-form numerics to modern modules and interfaces.
Adopting existing Fortran test conventions with Atlas
To maintain consistency, Atlas first identifies your project's existing Fortran test conventions, typically by grepping for an existing test file. This ensures new tests, like those in `test/my_module_test.f90`, match your repository's established framework, import style, and naming conventions, making integration direct.
A critical step in adding new tests is ensuring they conform to the existing codebase's style and structure. Atlas achieves this by using its `grep` tool to search for an existing test file within your Fortran project, often located under a `test/` directory. For instance, it might search for `use my_module` within `test/` to find relevant examples. By analyzing these existing files, Atlas learns the repository's preferred test framework, how modules are imported (e.g., `use my_module, only: my_subroutine`), and the naming conventions for test files and procedures. This capability prevents Atlas from inventing new conventions, instead ensuring that any new test file, such as `test/new_feature_test.f90`, aligns perfectly with your team's established Fortran development practices.
Generating new Fortran test files with Atlas
Once conventions are understood, Atlas uses its `write` tool to generate the new Fortran test specification file, such as `test/new_module_test.f90`. This process involves creating a unified diff for review, ensuring you have full control over 100% of changes before they are applied to disk, maintaining code integrity.
With a clear understanding of the module's interfaces and the project's testing conventions, Atlas proceeds to draft the new Fortran test file. Using its `write` tool, Atlas generates the content for a new test specification, for example, `test/my_new_module_test.f90`. This tool is designed with safety in mind: it first computes a unified diff of the proposed changes. This diff is then presented to you for explicit approval. This permission-gated approach means that no changes are written to your Fortran codebase without your direct consent, allowing you to review every line of the generated test code and ensure it meets your quality standards before it lands on disk.
Running and iterating on Fortran tests with `fpm test`
After generating the test file, Atlas executes the Fortran test suite using the `bash` tool to run `fpm test (test-drive)`. This immediate execution is crucial; a test that never runs is not a test, and Atlas can process output logs exceeding 2000 lines or 50 KB, saving the full log to a file.
The true value of a unit test lies in its execution. Atlas leverages its `bash` tool to run the Fortran test suite using the `fpm test (test-drive)` command. This command, part of the Fortran Package Manager, compiles and executes your tests. Atlas monitors the output, reading failures and diagnostics from `gfortran`. If the initial run reveals failures, Atlas enters an iterative loop. It uses its `edit` tool to modify the test file or the module under test, then re-runs `fpm test (test-drive)` until all tests pass. For large modules or complex test suites, Atlas can use its `todowrite` tool to keep track of progress, ensuring that even extensive testing efforts remain manageable. Output logs exceeding 2000 lines or 50 KB are truncated in the terminal but saved to a file for full review.
Ensuring Fortran code quality with `fprettify` and Atlas
Before approving any changes, Atlas can automatically run `fprettify` over the modified Fortran source files, ensuring adherence to your project's formatting standards. This step, often performed before the final diff approval, helps maintain a consistent code style across 100% of your codebase, from new tests to existing modules.
Maintaining a consistent code style is vital for readability and collaboration in Fortran projects. Before you finalize and approve the changes made by Atlas, it can automatically invoke the `fprettify` formatter. Using its `bash` tool, Atlas runs `fprettify` on the newly created or modified Fortran source files, such as `test/my_new_module_test.f90`. This ensures that the generated test code adheres to your project's established formatting rules. Atlas then computes a new unified diff that includes these formatting changes, presenting it for your final review. This ensures that not only is the code functionally correct, but it also meets your team's aesthetic and stylistic requirements before being committed to your Fortran repository.
Step by step
- 01Use `atlas read src/my_module.f90` to load the Fortran module under test into Atlas's context.
- 02Run `atlas lsp documentSymbol src/my_module.f90` to enumerate all public functions and subroutines in the Fortran module.
- 03Execute `atlas grep "use my_module" test/` to find existing Fortran test files and understand the project's testing conventions.
- 04Instruct Atlas to `atlas write test/my_new_module_test.f90` to generate the new Fortran test specification file, reviewing the unified diff.
- 05Use `atlas bash "fpm test (test-drive)"` to run the Fortran test suite and observe any failures or `gfortran` diagnostics.
- 06Iterate on test failures by using `atlas edit test/my_new_module_test.f90` to refine the Fortran tests or the module code until the suite is green.
- 07Before final approval, run `atlas bash "fprettify test/my_new_module_test.f90"` to ensure the new Fortran test file adheres to code formatting standards.
- 08Approve the final unified diff presented by Atlas to commit the new Fortran unit tests to your repository.
Frequently asked questions
- How does Atlas discover symbols in my Fortran modules?
- Atlas uses its `lsp` tool with the `documentSymbol` operation to parse your Fortran source files, such as `src/my_module.f90`, and enumerate all exported subroutines, functions, and variables, ensuring comprehensive test coverage.
- Can Atlas adapt to my existing Fortran test framework and style?
- Yes, Atlas is designed to adapt. It uses its `grep` tool to search for existing Fortran test files in your project, learning your repository's specific test framework, import styles, and naming conventions before generating new tests.
- What Fortran test runner does Atlas use for execution?
- Atlas integrates with the standard Fortran toolchain. It uses its `bash` tool to execute tests via the `fpm test (test-drive)` command, which is part of the Fortran Package Manager (`fpm`).
- How does Atlas ensure my Fortran code adheres to formatting standards?
- Before you approve any changes, Atlas can automatically run `fprettify` over the modified Fortran source files using its `bash` tool. This ensures that all new or edited code conforms to your project's established formatting rules.
- Is my Fortran source code sent to external servers when using Atlas?
- No, Atlas prioritizes local execution and privacy. It can build its code index with local Ollama embeddings, ensuring that your Fortran source code remains on your machine and is not sent to third-party servers.
- How does Atlas handle large output logs from Fortran test runs?
- When `fpm test (test-drive)` generates extensive output, Atlas truncates terminal display for logs exceeding 2000 lines or 50 KB. However, the full log is always saved to a file, which you can review at your convenience.
- What safety mechanisms does Atlas have for modifying Fortran code?
- Atlas employs several safety features. Every tool call is permission-gated, and it drafts a plan in a read-only agent first. Crucially, it computes a unified diff for every file edit and surfaces it for your explicit approval before writing any changes to your Fortran codebase.
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 Fortran: fpm.toml, Explicit Interfaces, and fprettify in 2026
Atlas is a terminal-native AI coding agent for Fortran in 2026. It reads modules, explicit interfaces, and intent declarations, runs fpm test behind a prompt, and runs fprettify.
Review a Fortran Pull Request with Atlas in 2026
Streamline Fortran pull request reviews in 2026 with Atlas. Leverage `fpm`, `fprettify`, and `gfortran` diagnostics to catch subtle bugs and ensure robust code quality.
Research a third-party API before integrating it in Fortran with Atlas in 2026
Fortran developers in 2026 can research third-party APIs efficiently with Atlas. Use `websearch` and `webfetch` for current docs, then integrate with confidence, verifying against `fpm` project conventions.
Run Atlas Headless in CI for Fortran in 2026
Fortran developers in 2026 can run Atlas headless in CI pipelines to automate tasks, integrate with fpm, and get machine-readable output for robust automation.
Onboard to an Unfamiliar Fortran Codebase in 2026 with Atlas
Quickly build a working mental model of any Fortran repository using Atlas. Leverage semantic search, `fpm` package layouts, and `fprettify` formatting for rapid understanding and safe code exploration in 2026.
Refactor a Legacy Fortran Module with Atlas in 2026
Modernize Fortran code in 2026. Use Atlas to refactor legacy modules, move COMMON blocks, and ensure no regressions with fpm test and fprettify.
Upgrade a Fortran Dependency and Fix Breakage with Atlas in 2026
Fortran developers in 2026 can use Atlas to upgrade dependencies, resolve compile errors, and fix test failures. Learn how Atlas integrates with fpm, gfortran, and fprettify for efficient migrations.