Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 6, 2026

Creates a daily workflow that identifies complex, under-tested functions and generates comprehensive tests. Uses Serena for complexity analysis and Go coverage data to rank functions by (complexity × inverse_coverage), targeting the highest-priority testing gaps.

Workflow Implementation

  • Trigger: Daily fuzzy schedule + manual dispatch
  • Function Selection:
    • Generates coverage with go test -coverprofile
    • Analyzes complexity via Serena MCP (cyclomatic complexity, branches, error paths)
    • Ranks functions: complexity score × (1 - coverage%)
    • Selects top function: most complex + least tested
  • Test Generation:
    • Analyzes function semantics (inputs, outputs, dependencies, edge cases)
    • Generates table-driven tests following codebase patterns
    • Covers happy path, edge cases, errors, all branches
    • Verifies tests pass and coverage improves
  • Output: Creates PR with [test] prefix, coverage metrics, and automation labels

Key Features

  • Serena MCP: Go code complexity analysis (not documented in workflow instructions)
  • Cache memory: Tracks processed functions across runs to avoid duplication
  • Single-function focus: One PR per day for high-quality, reviewable tests
  • Security: Read-only permissions, explicit bash command allowlist

Example workflow configuration:

tools:
  serena: ["go"]
  cache-memory: true
  github:
    toolsets: [default]
  edit:
  bash:
    - "go test -coverprofile=coverage.out ./..."
    - "go tool cover -func=coverage.out"

safe-outputs:
  create-pull-request:
    title-prefix: "[test] "
    labels: [testing, automation]

The workflow systematically eliminates testing debt by prioritizing functions where test investment has the highest impact.

Original prompt

Create an agentic workflow that finds messy functions with low coverage and add tests for it.

Use Serena to find the most complicated functions
Use test coverage data to find the least test function and most complicated

Focus on a single function and generate tests.

Runs daily.

Custom agent used: create-agentic-workflow
Design agentic workflows using GitHub Agentic Workflows (gh-aw) extension with interactive guidance on triggers, tools, and security best practices.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Add tests for complicated functions with low coverage Add test-coverage-improver workflow for automated test generation Jan 6, 2026
Copilot AI requested a review from pelikhan January 7, 2026 00:00
@pelikhan pelikhan marked this pull request as ready for review January 7, 2026 00:02
@pelikhan pelikhan merged commit de6e815 into main Jan 7, 2026
@pelikhan pelikhan deleted the copilot/focus-on-messy-function-tests branch January 7, 2026 00:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants