Todo.txt Testing: How to Test Your Command-Line Application with testRigor
|
|

Todo.txt is a plain-text approach to task management. Its open-source command-line client, todo.txt-cli, lets you add, organize, prioritize, and complete tasks without leaving the terminal. Todo.txt testing helps you verify that those commands continue to work and that the changes they make survive across terminal sessions.
A task manager can be deceptively simple to test. Adding a task may return a success message even though a later command cannot find it. Likewise, marking a task as done can remove it from the active list without establishing that the completed record is still available. A change to the shell environment can also affect how project and context tags are entered.
For developers who maintain command-line applications and users who customize their own Todo.txt setup, these are practical reasons to test complete workflows. The same approach is useful for other CLI tools that depend on keyboard input, local files, interactive prompts, and shell configuration.
What Should Todo.txt Testing Cover?
Todo.txt uses one line per task. In the official format, a priority can appear in parentheses, project tags begin with +, context tags begin with @, and a completed task starts with a lowercase x. For example, a task can belong to a work project and an office context at the same time.
(A) Review release notes +work @office
- Add, prioritize, complete, and archive a task
- Preserve active and completed tasks across sessions
- Filter tasks by project, context, and their intersection
- Append task details while retaining existing metadata
- Cancel and confirm deletion without removing unrelated tasks
- Remove duplicate entries while retaining distinct tasks
In addition, teams that rely on custom actions, reporting, alternative configuration files, or shell completion should test those behaviors separately. The six desktop scenarios in this article concentrate on the everyday task lifecycle.
What Todo.txt Already Checks, and What It Does Not
The upstream client includes a substantial shell test suite. Its tests cover configuration, adding and listing tasks, priority changes, completion, archiving, deletion, deduplication, reporting, and shell completion. The repository also documents make test as a way to execute the tests locally.
The existing GitHub Actions workflow runs lint checks and a build-and-test matrix on Linux, macOS, and Windows. On Windows, it installs Cygwin for the shell-based checks. In addition to the regular tests, the workflow checks distribution builds, installation, uninstallation, and cleanup.
Those checks already cover many CLI behaviors directly, so the desktop suite should complement them rather than reimplement every assertion. In particular, launching a packaged application in a Windows desktop session, entering commands through the keyboard, answering confirmation prompts, and reopening the terminal add a different kind of evidence.
Unit Testing in Todo.txt
Unit tests focus on small pieces of logic. In a shell application, useful candidates include parsing task metadata, interpreting options, formatting dates, and deciding how priorities should be represented. Developers can test these operations with controlled inputs and expected outputs.
Keep the checks narrow enough that a failure identifies a specific behavior. For example, an isolated parsing check can establish whether a priority is recognized correctly without opening a terminal window. The upstream shell suite also contains command-level regression tests, so not every existing test is a unit test.
Integration Testing in Todo.txt
Integration testing checks how the CLI works with its configuration, shell utilities, and local task files. For instance, completing a task with automatic archiving enabled should update the active and completed lists. A direct file assertion can confirm that the corresponding record was written to done.txt and is no longer present in todo.txt.
Use temporary files and a dedicated configuration for these checks. This makes it possible to inspect exact file contents and command exit codes without modifying a real task list. However, a successful shell-level test does not establish that a packaged launcher, terminal input, and interactive output work together in the intended desktop environment.
End-to-End Todo.txt Testing
A terminal is the user interface of a CLI application. End-to-end testing can therefore follow a complete sequence through that interface: open the application, enter a command, inspect the result, make another change, and reopen the application to check that the state persists.
For the task lifecycle, a useful journey is: add a task → assign a priority → complete it → check the completed list. Unlike a web application, Todo.txt CLI has no server endpoint or browser DOM to exercise. Select a tool that can interact with a terminal or run the shell program directly, depending on the behavior you need to test.
testRigor
With testRigor, you can write desktop automation in plain English. For a command-line application, the steps can type a shell command, press Enter, and inspect what appears on the screen. Reusable Rules can handle the launcher and reset process so that individual cases concentrate on the task workflow.
In this example, OCR checks stable text such as the readiness banner, while AI-based assertions describe the task rows, counts, and confirmation prompts expected on the screen. See the language documentation for the available commands.
Shell-Based Testing
The project already provides a shell test harness. For direct CLI assertions in Todo.txt testing, it is a good starting point: a script can run a command, compare stdout and stderr, inspect exit status, or compare the resulting files with expected contents. These checks can be more precise than visual assertions for exact text or file formats.
However, if you need to verify actual keyboard behavior, window launch, or the way output appears in a Windows terminal, use a desktop test alongside the shell checks.
Expect and Other Terminal Automation Tools
Expect is another option for automating interactive command-line programs. It can send input and wait for expected output in a terminal session, which is useful for scripts that prompt for confirmation. By contrast, a desktop-based tool can exercise the Windows launcher and visible console as part of the same test. Browser tools such as Selenium and Playwright are not the appropriate default for this native terminal workflow.
Todo.txt Testing with testRigor: How to Perform End-to-End Tests
The following example uses a source-built portable Windows x86_64 package from the demonstration pull request. It bundles a Bash runtime and tools, the Todo.txt CLI source, a package-local configuration, and a Windows launcher. This is an external demonstration in a fork, not a feature merged into the upstream project.
First, prepare the application package and confirm that it works on its own. Then configure a dedicated desktop test suite and import the rules that open the terminal and reset the test data. You do not need a public URL, a web server, Docker, or a localhost tunnel for this package.
Setting Up a Safe Environment for Todo.txt Testing
Important: Do not use your personal task file for these tests. The reset command deliberately empties the package-local task files. Deletion and deduplication tests also modify data, so use a dedicated disposable package.
On Windows x86_64, use Git and Python 3.13 with a checkout containing the demonstration files. The builder archives the checked-out commit, downloads checksum-pinned runtime and build tools, uses the upstream Makefile, and performs a package self-check.
python e2e/testrigor/ci.py build
The resulting file is artifacts/desktop-package/ci-build/todo-cli-desktop-win64.zip. Extract the complete ZIP and open Start-Todo.cmd to try it locally. The package already includes the shell runtime, so a separate Git installation, WSL, or administrator access is not required to launch the extracted application.
The command todo is provided by the package wrapper. It invokes the upstream shell script using the package configuration. Similarly, todo-reset and todo-status are test-environment helpers, not standard Todo.txt CLI commands. See the package and test setup guide for the build and launcher details.
Test Data for Todo.txt Testing
For Todo.txt testing, the package keeps its files separate from the normal user configuration. That gives each scenario a known starting state and avoids reading or deleting a developer’s own tasks.
| File or setting | Purpose |
|---|---|
data/todo.txt |
Active tasks |
data/done.txt |
Completed tasks |
data/report.txt |
Task statistics |
TODOTXT_AUTO_ARCHIVE=1 |
Automatically archive a task when it is completed |
TODOTXT_FORCE=0 |
Do not bypass confirmation prompts |
TODOTXT_DATE_ON_ADD=0 |
Do not automatically prepend a creation date |
TODOTXT_PLAIN=1 |
Use plain terminal output |
The walkthrough starts with a fixed task called smoke because it resets the task files before adding anything. Other cases generate a six-letter suffix and save it as fixture. Consequently, their assertions can distinguish the records created by that execution.
Generated names alone do not protect tests that share the same files. Use separate package data directories for concurrent executions, or run the cases serially when isolation has not been established.
Create a Native Desktop Test Suite
Step 1: Log in to the testRigor application. Create a test suite using a name such as Todo.txt CLI Regression.
Step 2: Set Type of testing to Native Desktop. Under Where to run the tests, select Use testRigor infrastructure to run tests on provided application and set OS to Windows. Set the number of AI-generated test cases to 0 for manual authoring. Under Upload file, choose the complete portable ZIP. The demonstrated suite uses a Windows desktop execution environment, recorded as DESKTOP_RDP. Refer to the Windows desktop testing setup example for the suite creation and upload workflow.
Step 3: Click Upload and Create. Next, add the four Reusable Rules from the demonstration files under e2e/testrigor/rules/. In particular, the launcher expects the extracted inner directory todo-cli-desktop-win64 beneath an upload folder on the desktop.
Step 4: Click Add Test Case, enter a descriptive name, and add the steps in the walkthrough below. Select Add and Run when the case and its rules are ready. If your hosted environment extracts applications differently, adjust the launcher after checking the actual directory layout.
Test Case: Complete a Task from the Windows Terminal
The first test checks that a user can add a task, give it priority A, and mark it as complete. It also verifies that the completed task is accessible through the CLI after automatic archiving. The sample uses the package settings described above.
Step 1: Open the Terminal and Reset the Test Data
The first reusable rule opens the application and checks the startup and readiness text. Then the reset rule empties the three package-local task files and checks that both the active and completed lists are empty. This ensures that task number 1 will refer to the new task.
windows-open-todo windows-reset-todo
Step 2: Add a Task and Verify the Active List
Enter the command exactly as a user would at the todo> prompt. The first assertion checks the acknowledgment. Next, clear the terminal and list the tasks, so the test does not accidentally match text left behind by the command that created the task.
type "todo add smoke" press enter check that page "shows confirmation that task number 1 was added" using ai type "clear" press enter type "todo ls" press enter check that page "shows one active task named smoke" using ai

Step 3: Assign a Priority
Use the task number to assign priority A. A fresh list should show the task with the priority marker (A). This checks the visible result of the operation rather than relying on the command acknowledgment alone.
type "todo pri 1 A" press enter type "clear" press enter type "todo ls" press enter check that page "shows task smoke with priority A displayed as (A)" using ai

Step 4: Complete and Archive the Task
With automatic archiving enabled, completing task 1 should leave no active tasks. However, that result alone would also be consistent with losing the task. Inspect done.txt through the CLI to check the completion marker, date, task name, and completed-list count.
type "todo do 1" press enter type "clear" press enter type "todo ls" press enter check that page "shows the todo list summary reporting zero of zero tasks" using ai type "todo listfile done.txt" press enter check that page "shows a completed task named smoke with an x completion marker and a completion date after the displayed task number" using ai check that page "shows the DONE list summary reporting one of one tasks" using ai

Finally, reset the test package, exit the terminal, and check that its title is no longer visible. The complete case includes those cleanup steps.
Complete Test Case
windows-open-todo windows-reset-todo type "todo add smoke" press enter check that page "shows confirmation that task number 1 was added" using ai type "clear" press enter type "todo ls" press enter check that page "shows one active task named smoke" using ai type "todo pri 1 A" press enter type "clear" press enter type "todo ls" press enter check that page "shows task smoke with priority A displayed as (A)" using ai type "todo do 1" press enter type "clear" press enter type "todo ls" press enter check that page "shows the todo list summary reporting zero of zero tasks" using ai type "todo listfile done.txt" press enter check that page "shows a completed task named smoke with an x completion marker and a completion date after the displayed task number" using ai check that page "shows the DONE list summary reporting one of one tasks" using ai windows-reset-todo type "exit" press enter check that page does not contain "todo.txt CLI" using OCR
These are the task-lifecycle steps from the example suite and the current pull request. The rule definitions and portable launcher must be available before the case can run.
Execution Results
The demonstration’s recorded Windows desktop execution passed all six task scenarios. Its GitHub Actions run reports zero JUnit failures, errors, or skips for an earlier source revision. The example test execution records also show all six cases passing in a separate run associated with the v2.15.0 release commit.
In testRigor, use the execution report to inspect the failed step, screenshots, and execution time. For terminal applications, the screenshot can help identify whether a command was entered incorrectly, the application did not launch, or the displayed state differs from the expected result. The six desktop cases check visible output; the separate package self-check includes direct file assertions.
You can find the source-controlled cases in the demonstration PR. The corresponding testRigor run belongs to a private suite and is not publicly available.
testRigor Capabilities for CLI Applications
- Reusable Rules: Keep launch, readiness, reset, and exit steps separate from task assertions.
- Stored values and generated data: Generate fixture names and refer to the same task in later assertions.
- Keyboard automation: Enter commands, submit them with Enter, and send key combinations for special characters.
- OCR and AI-based assertions: Check stable visible text or describe the expected task rows and counts.
- Execution screenshots: Inspect what was actually displayed when a step ran.
- CI/CD integration: Upload a source-built package and run repository-controlled cases with the testRigor CLI.
For more examples, see the language reference, testRigor features, and end-to-end testing guide.
High-Value Todo.txt Testing Scenarios
Once the task lifecycle works, expand the suite to cover state changes that a user might not notice immediately. The following scenarios use the same Windows package and reusable setup as the first example. Each code excerpt is part of a longer case; use the complete repository definitions when running the entire suite.
1. Verify Persistence Across Terminal Sessions
Create two distinct tasks and complete the first one. The second should remain active, while the first should appear in the completed list. Then close and reopen the terminal without calling the reset rule. The persistence check would be meaningless if the test recreated those tasks after reopening.
generate from regex "[a-z]{6}", and save as "fixture"
type string with parameters "todo add done${fixture}"
press enter
type string with parameters "todo add keep${fixture}"
press enter
type "todo do 1"
press enter
type "clear"
press enter
type "todo ls"
press enter
check that page string with parameters "shows exactly one active task named keep${fixture} and the TODO summary reports one of one tasks" using ai
type "clear"
press enter
type "todo listfile done.txt"
press enter
check that page string with parameters "shows exactly one completed task named done${fixture} with an x marker and completion date, and the DONE summary reports one of one tasks" using ai
After relaunching the same extracted package, repeat the active-list and completed-list assertions. The full case verifies both states before and after reopening. This is session persistence coverage; it does not establish synchronization between different devices or storage providers.

2. Filter Tasks by Project and Context
Projects and contexts let a user narrow a long list to relevant tasks. For a meaningful test, create three records with overlapping tags: one with +w @h, one with +w @o, and one with +p @h. A project-only filter should return two tasks, as should the context-only filter. Their intersection should return exactly one.
During desktop testing, entering whole tag strings corrupted the symbols in the tested terminal. The suite therefore types the plus and at signs using explicit keyboard combinations. These sequences correspond to the tested keyboard layout and should be revalidated on other layouts.
type "clear"
press enter
type "todo ls"
press space
press shift+=
type "w"
press space
press shift+2
type "h"
press enter
check that page string with parameters "shows only the task row a${fixture}, no task rows for b${fixture} or c${fixture}, and the TODO summary reports one of three tasks" using ai
The assertion checks that the matching task is present, the other two rows are absent, and the summary reports one of three tasks. Finally, list all tasks again to confirm that filtering did not remove them.

3. Append Details Without Losing Priority or Tags
Users often add details to an existing task instead of replacing it. Create a task with project and context tags, assign priority A, and append the word revised. The edited task should retain its original text and metadata.
type "todo append 1 revised"
press enter
type "clear"
press enter
type "todo ls"
press enter
check that page string with parameters "shows exactly one task with the full text edit${fixture} +w @h revised, still with priority (A), and the TODO summary reports one of one tasks" using ai

The complete case then reopens the application and repeats the assertion. As a result, the test covers both the edit and its persistence across a new terminal session.
4. Cancel and Confirm Deletion
An interactive deletion test needs to cover both choices. Create two records, drop${fixture} and keep${fixture}, with the generated suffix. First, request deletion of task 1 and answer n. Both tasks should still appear in the next list.
type "todo del 1"
press enter
check that page string with parameters "shows a pending deletion confirmation for drop${fixture} with a y/n choice" using ai
type "n"
check that page "shows a cancellation message saying no tasks were deleted and the shell prompt has returned" using ai
type "clear"
press enter
type "todo ls"
press enter
check that page string with parameters "shows task rows for both drop${fixture} and keep${fixture}, and the TODO summary reports two of two tasks" using ai

Next, request deletion again and answer y. Check the updated active list for the retained task and the absence of the deleted one. Also inspect the completed list: deletion is a different action from completion, and this case expects no completed records.
5. Remove Duplicate Captures and Preserve Distinct Tasks
A user may accidentally capture the same task twice. Deduplication should remove the redundant record without affecting a different task. The test creates two identical dup${fixture} records and one keep${fixture} record, then confirms the starting count is three.
type "todo deduplicate"
press enter
type "clear"
press enter
type "todo ls"
press enter
check that page string with parameters "shows exactly one task row dup${fixture} and exactly one task row keep${fixture}, and the TODO summary reports two of two tasks" using ai
After reopening the terminal, the full test checks that the two distinct rows remain. This protects against a misleading success message or a change that is visible only in the current session.

Reusable Rules for Todo.txt Testing
e2e/testrigor/rules/:- Launch the application and verify readiness with
windows-open-todo. - Reset package-local data and check both lists with
windows-reset-todo. - Exit and check that the terminal title is no longer visible with
windows-close-todo. - Combine reset and close for final cleanup with
windows-reset-and-close-todo.
The launcher opens PowerShell to find the actual extracted package. In particular, it expects one matching inner launcher path beneath the desktop upload directory. This avoids hard-coding the timestamped outer folder name.
windows-open-todo as follows:press win+r type "%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe -NoProfile" press enter check that page contains "Windows PowerShell" using OCR and stop test if fails type "$ErrorActionPreference='Stop'" press enter type "& (Get-Item $env:USERPROFILE\Desktop\*\todo-cli-desktop-win64\Start-Todo.cmd).FullName; exit" press enter check that page contains "todo.txt CLI - portable Windows test environment" using OCR and stop test if fails type "todo-status" press enter check that page contains "Ready: source-built Windows CLI" using OCR and stop test if fails
This rule checks readiness before allowing a task test to proceed. The reset rule should be called before a new scenario, but not between the close and reopen steps of a persistence test. Import the exact remaining rule definitions from the pull request.
Todo.txt Testing Tips for Reliable Automation
- Clear stale output. Run
clearbefore listing tasks, especially when checking that a record is absent. Otherwise, earlier terminal output may still be visible. - Check the result after an acknowledgment. A completed task should appear in the archive; a canceled deletion should leave both tasks in the active list.
- Use the correct keyboard layout. The tested Windows environment uses explicit key sequences for
+and@. Revalidate these on other layouts. - Combine visual and direct assertions. OCR worked for stable readiness text; exact OCR caused false failures for some terminal counts and acknowledgments during implementation. AI assertions were used for those visible states. Keep shell tests for exact file contents and exit codes.
- Keep configuration predictable. Automatic archiving, date insertion, forced deletion, and color settings can change expected output. Match the test configuration to your intended behavior.
- Isolate data. The recorded case flows overlapped despite the suite reporting one configured node. Do not assume node count guarantees file isolation. Coordinate concurrent runs and reset only disposable data.
When to Run Your Todo.txt Testing Suite
Use desktop cases in your Todo.txt testing strategy when changes could affect the experience of launching or interacting with the CLI. For example, run the task lifecycle and persistence tests after changing the launcher, shell runtime, package configuration, or task file handling. Recheck tag input after a keyboard layout or terminal change.
For routine development, keep the existing shell tests in the normal CI workflow. A short desktop smoke test is useful before releasing a new package, while the full six-case suite gives broader coverage of interactive behavior. Teams can choose when to run that additional layer according to release risk and available test infrastructure.
Todo.txt Testing in GitHub Actions
For teams that distribute a CLI package, it is useful to connect desktop testing to the source revision being built. The fork demonstration provides a manual GitHub Actions workflow that builds the checked-out source into a portable Windows ZIP, verifies the package, and then runs the six desktop cases through testRigor.
Existing upstream native CI remains unchanged. The additional workflow is opt-in, runs only on manual dispatch from the default branch after integration, and is not configured as a required pull-request check.
Configure the Test Suite and Credentials
Use a dedicated Windows desktop suite. In the GitHub repository, open Settings → Secrets and variables → Actions and configure the following values:
| Type | Name | Purpose |
|---|---|---|
| Secret | TESTRIGOR_CI_TOKEN |
Credential authorized for the suite |
| Variable | TESTRIGOR_SUITE_ID |
Dedicated Windows desktop suite ID |
| Variable | TESTRIGOR_E2E_ENABLED |
Set to true to enable the workflow |
The suite ID is in the testRigor suite URL. The workflow maps the GitHub secret into TESTRIGOR_API_KEY for the CLI. See GitHub’s guides to secrets and variables for configuration details.
Build and Run the Desktop Tests
The implementation pins Node.js and testRigor CLI versions and uses Python to build and verify the package. The following excerpt runs after the Windows job has checked out the code and set up Python and Node.js.
- name: Install pinned CLI run: npm install --global @testrigor/[email protected] - name: Build checked-out source and verify package run: python e2e/testrigor/ci.py build - name: Run contributed cases against this build env: TESTRIGOR_API_KEY: ${{ secrets.TESTRIGOR_CI_TOKEN }} TESTRIGOR_SUITE_ID: ${{ vars.TESTRIGOR_SUITE_ID }} SOURCE_BRANCH: ${{ github.ref_name }} SOURCE_COMMIT: ${{ github.sha }} run: python e2e/testrigor/ci.py run
The Python runner invokes the testRigor CLI with --file-path to upload the ZIP, --test-cases-path and --rules-path for the repository definitions, and branch/commit metadata. It also requests a JUnit report. Routine CI omits --explicit-mutations, so it does not authoritatively replace the stored suite.
Keep Execution Evidence and Coordinate Runs
The workflow skips the desktop job if the opt-in flag, suite ID, or credential is missing. When enabled, it checks that the package matches the checkout and records the source commit, package checksum, and harness hashes. A successful CLI exit alone is insufficient: the runner also requires a complete passing JUnit report, using a fallback collector when necessary.
The workflow retains JUnit, redacted CLI logs, and build and identity records as artifacts. In addition, testRigor keeps the screenshots from the desktop run. These records make it easier to distinguish a package build problem from a terminal automation failure.
The demonstration serializes workflow access to a suite within the repository. Coordinate other repositories and local executions as well, because the CLI can cancel an active run. If a GitHub job times out, check whether the remote suite is still running before dispatching it again. The complete setup guide describes the configuration and artifact retention.
Conclusion
Todo.txt testing is particularly useful when it protects the operations that people rely on every day: adding tasks, organizing them, completing them, and finding them again in another terminal session. Existing shell tests provide precise checks of command behavior and file contents; desktop automation adds evidence about the packaged application and its interactive interface.
Start with the task lifecycle in a disposable Windows package. Then extend the suite to cover persistence, filtering, editing, deletion, and duplicate removal. The same testing approach can help you protect other command-line applications whose users depend on reliable keyboard input and durable local state.
| Achieve More Than 90% Test Automation | |
| Step by Step Walkthroughs and Help | |
| 14 Day Free Trial, Cancel Anytime |




