test-coverage-improvement

test-coverage-improvement is a cursor rule for Cursor from prassanna-ravishankar/clearml-mcp. It costs 0 tokens per session (666 once invoked), scanned A, original, MIT.

A set of testing rules and patterns based on a project that raised test coverage from 34% to 69%. It favors tests of public behavior and expected results over tests tied to internal code structure.

In plain words
What is it for?
Use it when rewriting tests, adding edge cases, mocking external services, or checking that a public API behaves correctly.
Why use it?
Behavior-focused tests are less likely to break during refactoring and cover missing data, empty responses, errors, and varied response formats.

Cursor rule for Cursor

Written for Cursor: installed under .cursor/.

Good fit Use it when rewriting tests, adding edge cases, mocking external services, or checking that a public API behaves correctly.

Compare 6 cursor rules from other repositories ↓
Install with agentmods
npx agentmods add rules/prassanna-ravishankar/clearml-mcp/test-coverage-improvement
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Clone the repo
git clone --depth 1 https://github.com/prassanna-ravishankar/clearml-mcp

Made for: Cursor.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for test-coverage-improvement

README.md
[![agentmods](https://agentmods.dev/badge/rules/prassanna-ravishankar/clearml-mcp/test-coverage-improvement/github.svg)](https://agentmods.dev/rules/prassanna-ravishankar/clearml-mcp/test-coverage-improvement)
Your own site
<a href="https://agentmods.dev/rules/prassanna-ravishankar/clearml-mcp/test-coverage-improvement"><img src="https://agentmods.dev/badge/rules/prassanna-ravishankar/clearml-mcp/test-coverage-improvement/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for test-coverage-improvement

Your own site · 80×15
<a href="https://agentmods.dev/rules/prassanna-ravishankar/clearml-mcp/test-coverage-improvement"><img src="https://agentmods.dev/badge/rules/prassanna-ravishankar/clearml-mcp/test-coverage-improvement.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 666 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00000 $0.00666
Opus 5 $0.00000 $0.00333
Sonnet 5 $0.00000 $0.00133
Haiku 4.5 $0.00000 $0.00067

Measured 10d ago against content hash 1202ec5afbe4, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-09, from the pricing page.

Security

Grade A, and why

test-coverage-improvement scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 10d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.cursor/rules/test-coverage-improvement.mdc · 86 lines

How it starts

The opening of the file, as written. The whole thing — 86 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Test Coverage Improvement: From 34% to 69%

Achievement Summary

Improved test coverage by +35 percentage points (34% → 69%) through comprehensive behavioral testing rewrite.

What We Learned

❌ White-Box Testing Problems (Original 34%)

  • Brittle tests that broke during refactoring
  • Implementation-dependent test structure
  • Incomplete coverage of public API behaviors
  • Hard to maintain when internal code changed

✅ Behavioral Testing Success (New 69%)

  • Stable tests that survive refactoring
  • Complete public API coverage - every function tested
  • Realistic scenarios with proper edge case handling
  • Easy to maintain - tests focus on contracts, not internals

Key Implementation Patterns

Comprehensive Mock Strategy

# Mock external dependencies completely
@patch('clearml.Task.get_task')
@patch('clearml.Task.query_tasks')
# Test all public API paths with realistic data

Edge Case Coverage

  • Missing attributes: Handle optional fields gracefully
  • Empty responses: Test when API returns no data
  • Error conditions: Test exception handling paths
  • Different data structures: Test various response formats

Proper Mock Attribute Handling

# Correct way to mock optional attributes
with patch('builtins.hasattr') as mock_hasattr:
    mock_hasattr.side_effect = lambda obj, attr: not (obj is mock_obj and attr == "missing_field")

Coverage Configuration

Configuration in pyproject.toml:

[tool.coverage.run]
branch = true
source = ["src"]
omit = ["_*.py", "__*.py"]

[tool.coverage.report]
skip_empty = true
show_missing = true
fail_under = 65  # Raised from default after improvement

Testing Commands

# Coverage testing (matches CI exactly)
coverage run -m pytest tests && coverage report

# Local development
uv run pytest --verbose --color=yes tests
uv run coverage run -m pytest tests && uv run coverage report

Success Metrics

  • Coverage: 69% (vs 34% before)
  • Test count: 26 comprehensive behavioral tests
  • API coverage: All public functions tested
  • Edge cases: Missing data, errors, empty responses
  • Stability: Tests survive refactoring
  • CI integration: Passes in all environments

Read the full file on GitHub · 86 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 10d ago First seen · 86 lines · 0 tokens per session scan A 1202ec5afbe4

Subscribe to this mod's changes

test-coverage-improvement is a cursor rule published in the GitHub repository prassanna-ravishankar/clearml-mcp (16 stars, last pushed 2mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 666 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.