๐ Changed Methods Only
Early PR and commit agents determine which code to generate tests for
This document explains how the --changed-methods-only flag and the CHANGED_METHODS_ONLY environment variable affect test generation behavior.
๐ง Core Test Selection Logicโ
At a high level, Early always starts from the same base logic:
- Identify public methods
- Filter methods below the coverage threshold
(currently treated as zero coverage) - Generate tests only for methods that meet these criteria
The changed-methods-only setting adds an additional filter layer on top of this logic.
๐ Default Behavior (Recommended)โ
For PR-based and commit-based agents, the default behavior is:
- Generate tests only for public methods that were added or changed
- Ignore unchanged methods, even if they are below coverage
This keeps test generation:
- Focused on the current change
- Faster and more predictable
- Aligned with typical CI workflows
This behavior is enabled by default.
โ๏ธ Configuration Optionsโ
You can control this behavior using either a CLI flag or an environment variable.
CLI Flagโ
--changed-methods-only true | false
Environment Variableโ
export CHANGED_METHODS_ONLY=true | false
Both options are equivalent.
๐งช Behavior Matrixโ
| Mode | What Gets Tested |
|---|---|
true (default) | Public methods that were added or changed and are below coverage |
false | All public methods below coverage, regardless of recent changes |
๐ง When to Set falseโ
You may want to disable changed-only filtering when:
- Running repository-wide cleanup or refactoring
- Backfilling tests for legacy code
- Running scheduled or one-off coverage improvement jobs
- Running PR or commit flows where you want broader test generation
In these cases, Early will generate tests for all eligible public methods, not just recently modified ones.
๐งช Example: GitHub Actionsโ
env:
CHANGED_METHODS_ONLY: "false"
This forces test generation for all public methods below coverage.
๐งช Example: Jenkinsโ
environment {
CHANGED_METHODS_ONLY = 'false'
}
Or inline before running the CLI:
export CHANGED_METHODS_ONLY=false
early generate-pr # or early generate-commit
๐ Notesโ
- This setting applies only after coverage and visibility filtering.
- It does not affect how coverage is calculated.
- For PR and commit agents,
trueis strongly recommended for day-to-day usage. - This setting applies only to PR and commit-based agents.
- It is ignored by repository-wide agents such as
generate-for-project.
โ Summaryโ
| Setting | Default | Effect |
|---|---|---|
--changed-methods-only | true | Limit test generation to changed public methods |
CHANGED_METHODS_ONLY | true | Environment-based equivalent |
| Applies to | PR / Commit agents | Controls method selection scope |
This option allows you to balance signal vs. coverage, depending on whether your goal is incremental validation or broad test generation.