Write tests

From Llloooggg/LetsFLUTssh · View interactive version

Write tests is an AI agent skill from the GitHub repository Llloooggg/LetsFLUTssh. Check SonarCloud coverage and write missing tests for uncovered lines. Use when user wants to improve test coverage.

How to use this skill

Skill file

Write tests for uncovered code

Step 1: Get current coverage from SonarCloud

Per-file coverage (worst files first):

curl -s "https://sonarcloud.io/api/measures/component_tree?component=Llloooggg_LetsFLUTssh&metricKeys=uncovered_lines,lines_to_cover,coverage&strategy=leaves&ps=50&s=metric&metricSort=uncovered_lines&asc=false" | python3 -c "
import json, sys
d = json.load(sys.stdin)
print(f\"{'File':<60} {'Coverage':>8} {'Uncovered':>9} {'Total':>5}\")
print('-' * 85)
for c in d.get('components', []):
    m = {x['metric']: x.get('value','?') for x in c.get('measures',[])}
    name = c['path']
    print(f\"{name:<60} {m.get('coverage','?'):>7}% {m.get('uncovered_lines','?'):>9} {m.get('lines_to_cover','?'):>5}\")
"

New code coverage:

curl -s "https://sonarcloud.io/api/measures/component?component=Llloooggg_LetsFLUTssh&metricKeys=new_coverage,new_uncovered_lines,new_lines_to_cover"

If $ARGUMENTS contains a file path, focus on that file only.

Step 2: Get uncovered line ranges

For each target file, fetch exact uncovered lines:

curl -s "https://sonarcloud.io/api/sources/show?component=Llloooggg_LetsFLUTssh:FILEPATH&from=1&to=9999" | python3 -c "
import json, sys
d = json.load(sys.stdin)
for line in d.get('sources', []):
    if line.get('lineHits', None) == 0:
        print(f\"  L{line['line']}: {line['code'][:100]}\")
"

Step 3: Read source and existing tests

For each file to cover:

  1. Read the source file to understand the code
  2. Find existing test file: test/ mirror of lib/ path (e.g., lib/core/ssh.dart → test/core/ssh_test.dart)
  3. Read the existing test file to understand what's already tested

Step 4: Write tests

Follow AGENTS.md "Testing Methodology" — it covers the three hard-to-remember invariants:

When in doubt re-read those sections in AGENTS.md verbatim; they are not paraphrased here on purpose.

Skill-specific additions:

Step 5: Verify coverage improved

Run tests and check coverage:

make test

Then compare with SonarCloud numbers. Note: local lcov.info may lag behind SonarCloud — for authoritative numbers, push and wait for CI, or use the API after CI completes.

Prioritization

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.