agentleFS
s-morgan-jeffriess-morgan-jeffries/omnifocus-mcp/.claude/skills/integration-testing/SKILL.md

integration-testing

Skill8 starsChanged 8 months agoMITView on GitHub

Use when setting up, running, or debugging integration tests against real OmniFocus. Also use when unit tests pass but behavior seems wrong, when adding new AppleScript operations, or when you need to understand why mocked tests are insufficient for this project. Covers the test database system, fixture setup, and the specific class of bugs that only integration tests catch.

12 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use error-handling.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • MicrosoftSkill

    error-handling

    统一错误处理系统。在添加 API 端点、修改错误处理、添加前端 API 调用、编写错误相关测试时使用。

    Also in 3 projects that use this

The file

We split this skill into the rules it gives an agent

8 rules. 0 are common, 5 are distinctive, and 3 are very specific to this project.

  • 0

    Common

    Most of the 9 edited versions we read keep these.

  • 5

    Distinctive

    This author's own choices. Worth a look.

  • 3

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Test database must be active (check with ./scripts/local/switch_to_test_db.sh)

    line 70
  2. Distinctive:

    Test fixtures must be loaded

    line 71
  3. Distinctive:

    Always clean up created data (delete tasks/projects you create)

    line 118
  4. Very specific:

    Use @pytest.mark.integration to allow selective running

    line 119
  5. Distinctive:

    Test against known fixture data when possible

    line 120
  6. Distinctive:

    Verify both the happy path and error cases (e.g., invalid IDs)

    line 121
  7. Distinctive:

    Every CRUD connector method should have a minimal integration test:

    line 139
  8. Very specific:

    Use try/finally for cleanup.

    line 146

“Common” is measured: kept by at least 6 in 10 of the 9 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

OmniFocus Integration Testing

Unit tests in this project mock AppleScript execution. This is fast but dangerous — mocked tests cannot catch AppleScript-level bugs. Integration tests run against a real OmniFocus instance and have caught critical bugs that unit tests missed.

Why Integration Tests Matter Here

The elifintervalDays story: A variable naming typo in AppleScript went undetected by 400+ unit tests because they mocked run_applescript(). The AppleScript was syntactically valid Python-side, but at runtime, AppleScript interpreted elifintervalDays as something unexpected. Only integration tests against real OmniFocus caught it.

Classes of bugs only integration tests catch:

  • Variable naming conflicts with OmniFocus properties (see applescript-omnifocus skill)
  • AppleScript syntax that's valid but produces wrong results
  • OmniFocus version-specific behavior changes
  • Timing issues with AppleScript execution
  • Rich text handling inconsistencies
  • Recurring task completion behavior differences

Test Database Setup

Integration tests use a separate OmniFocus database to prevent production data corruption.

Initial Setup

# Create test database in OmniFocus
# File > New Database > name it "OmniFocus-TEST"

# Set environment variables
export OMNIFOCUS_TEST_MODE=true
export OMNIFOCUS_TEST_DATABASE=OmniFocus-TEST.ofocus

# Generate test fixtures
./scripts/setup_test_database.sh

Switching Databases

# Switch to test database (sets env vars, switches OmniFocus)
./scripts/local/switch_to_test_db.sh

# Switch back to production
./scripts/local/switch_to_prod_db.sh

Cleaning Up

# Remove test data (keeps database)
./scripts/cleanup_test_data.sh

Running Integration Tests

# All integration tests
make test-integration

# Specific test file
pytest tests/test_integration_real.py -v

# E2E tests (full MCP stack)
make test-e2e
pytest tests/test_e2e_real.py -v

Prerequisites:

  • OmniFocus must be running
  • Test database must be active (check with ./scripts/local/switch_to_test_db.sh)
  • Test fixtures must be loaded

Three-Tier Testing Strategy

TierSpeedWhat it catchesWhen to run
Unit (mocked)~2min, 544 testsPython logic errors, parameter validation, response formattingEvery change (make test)
Integration (real OF)~30sAppleScript bugs, OmniFocus API quirks, variable naming conflictsNew AppleScript code, before merge
E2E (full MCP)~30sMCP tool registration, parameter passing, end-to-end flowNew/modified tools, before release

Test Fixtures

The project uses TaskPaper-format fixtures for consistent test data. Test fixtures are defined in scripts and imported into OmniFocus via AppleScript.

Key fixture scripts:

  • scripts/setup_test_database.sh — Basic fixtures (projects, tasks, tags)

Fixture design principles:

  • Fixtures create known-state data that tests can assert against
  • Each test file documents which fixtures it depends on
  • Fixtures are idempotent — running setup twice doesn't create duplicates

Writing Integration Tests

import pytest

# Mark as integration test (skipped unless test DB is active)
@pytest.mark.integration
def test_create_and_retrieve_task():
    """Integration test against real OmniFocus."""
    client = OmniFocusConnector(enable_safety_checks=True)

    # Create
    task_id = client.create_task(name="Integration Test Task", project_name="Test Project")
    assert task_id is not None

    # Retrieve and verify
    tasks = client.get_tasks(task_id=task_id)
    assert len(tasks) == 1
    assert tasks[0]["name"] == "Integration Test Task"

    # Cleanup
    client.delete_tasks(task_id)

Key patterns:

  • Always clean up created data (delete tasks/projects you create)
  • Use @pytest.mark.integration to allow selective running
  • Test against known fixture data when possible
  • Verify both the happy path and error cases (e.g., invalid IDs)

When to Write Integration Tests

Always write integration tests when:

  • Adding or modifying AppleScript code
  • Changing how data is serialized/deserialized from OmniFocus
  • Adding new filter parameters to get_tasks() or get_projects()
  • Modifying recurring task handling
  • Changing date conversion logic

Unit tests are sufficient when:

  • Changing Python-only logic (formatting, validation)
  • Modifying server-level parameter handling
  • Updating response formatting in server_fastmcp.py

Smoke Test Pattern for CRUD Operations

Every CRUD connector method should have a minimal integration test:

  1. Create — make a test entity, verify it gets an ID back
  2. Read — fetch it, verify the fields match what was created
  3. Update — change a field, re-fetch, verify the change took
  4. Delete — delete it, verify it's gone

Use try/finally for cleanup. Prefix test data with test- or Test .

tag_id = None
try:
    tag_id = client.create_tag(f"test-integ-{uuid.uuid4()}")
    assert tag_id  # Create returns ID
    tags = client.get_tags()
    assert any(t['id'] == tag_id for t in tags)  # Read confirms
finally:
    if tag_id:
        try:
            client.delete_tags(tag_id)
        except Exception as e:
            warnings.warn(f"Cleanup failed: {e}")

Detailed Setup Guide

For complete setup instructions including troubleshooting, see docs/guides/INTEGRATION_TESTING.md.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.