Skip to content

refactor(tests): improve test quality and remove test smells - #1141

Merged
25 commits merged into
tirth8205:stagingfrom
caduteix:refatoracao-test-smells
Nov 6, 2026
Merged

25 commits merged into
tirth8205:stagingfrom
caduteix:refatoracao-test-smells

Conversation

@caduteix

Copy link
Copy Markdown
Contributor

Summary

This PR refactors test methods in the CodeReviewGraph test suite to address common test smells, improving readability, maintainability, and test clarity while aiming to preserve existing test behavior.

The refactorings were guided by the CATSPY catalog and validated using Pytest and TEMPY.

Changes

  • Conditional Test Logic (tests/test_genai_packaging.py, tests/test_tools.py, tests/test_changes.py, and others): Replaced conditional checks and loops with direct assertions, collection-based checks, and Pytest parametrization to make test scenarios more explicit.
  • Unknown Test (tests/test_embeddings.py, tests/test_search_quality.py, and others): Added explicit assertions to verify expected results instead of relying exclusively on the absence of exceptions.
  • Exception Handling (tests/test_cli.py, tests/test_embeddings.py, and others): Simplified exception-related test logic using clearer verification strategies.
  • Verbose Test (tests/test_communities.py, tests/test_eval.py, tests/test_concurrency_and_daemon.py, and others): Extracted reusable helper functions and reorganized lengthy tests to improve readability and reduce duplication.

Validation

  • TEMPY: Total detected test smells decreased from 1,700 to 1,626 (74 fewer occurrences).
  • Pytest: Refactored tests were validated individually. The full suite still contains failures, including pre-existing failures.
  • Coverage: Remained approximately stable (83.36% before, 83.37% after).
  • Ruff: All checks passed.
  • Mypy: No issues found in 77 source files when targeting Linux.

Notes

Changes are limited to the test suite. No production code or measurement artifacts are included in this PR.

caduteix and others added 25 commits October 26, 2026 18:28
…ional-test-logic

refactor(tests): remove Conditional Test Logic occurrences
…est_embeddings.py, tests/test_search_quality.py, tests/test_watch_robustness.py
…n-test

refactor(tests): remove Unknown Test occurrences
…ion-handling

refactor(tests): simplify exception handling in tests
…e-test

refactor(tests): remove Verbose Test occurrence

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are blocking this test-suite refactor.

No open issues 🎉

What changed in this PR

This PR refactors the test suite to make scenarios and expected outcomes clearer, without changing production code.

Changes:

  • Replaces conditional checks with direct assertions, collection comparisons, and parametrized cases.
  • Adds explicit outcome checks and simplifies exception assertions.
  • Extracts setup helpers and improves database resource cleanup.
File Description
tests/​test_watch_robustness.py Verifies invalid paths leave the graph empty.
tests/​test_tools.py Strengthens flow filtering, truncation, and community assertions.
tests/​test_token_budget.py Requires nonempty affected flows without step lists.
tests/​test_search_quality.py Adds explicit search-result and mode assertions.
tests/​test_python_relative_imports.py Collects and validates path-shaped import targets.
tests/​test_multilang.py Simplifies parser assertions and exception handling.
tests/​test_main.py Parametrizes expected tool offloading behavior.
tests/​test_import_scope.py Checks the exact expected import targets.
tests/​test_genai_packaging.py Parametrizes locked-package source validation.
tests/​test_export_formats.py Simplifies YAML frontmatter validation.
tests/​test_eval.py Reuses repository, graph, and benchmark setup helpers.
tests/​test_embeddings.py Adds a removal assertion and explicit exception expectations.
tests/​test_embedding_refresh.py Extracts mocked MCP invocation setup.
tests/​test_embedding_initialization.py Extracts concurrent model-constructor setup.
tests/​test_daemon.py Extracts reconciliation setup and checks rejected writes preserve configuration.
tests/​test_cpp_overload_identity.py Extracts reindexing and edge-lookup helpers.
tests/​test_concurrency_and_daemon.py Extracts migration database and rapid file-change setup.
tests/​test_communities.py Extracts sparse-graph and community-splitting scenarios.
tests/​test_cli.py Simplifies exit assertions and extracts repository setup.
tests/​test_changes.py Requires multiple priorities and verifies descending risk order.
tests/​test_call_site_provenance.py Uses temporary-path and context-managed migration setup.
tests/​test_auto_promote.py Validates workflow step references as a set.
tests/​test_agent_transparency.py Extracts Java qualified-name graph setup.

Review effort: Balanced

@tirth8205 tirth8205 closed this pull request by merging all changes into tirth8205:staging in 0160eb0 Nov 6, 2026
gowrishacv pushed a commit to gowrishacv/code-review-graph that referenced this pull request Nov 6, 2026
… (review of tirth8205#1141)

Restores the comments that explain why tests are shaped as they are,
puts the Portuguese comments into English, clears new ruff findings,
names the bad pages again in the Obsidian YAML test, and reads uv.lock
when the source guard runs rather than at collection.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
gowrishacv pushed a commit to gowrishacv/code-review-graph that referenced this pull request Nov 6, 2026
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.

4 participants