Skip to content

Comments

feat(discovery): transitive inheritance, inherited methods, and bare test support#94

Merged
NikkeTryHard merged 1 commit intomasterfrom
fix/class-inheritance-discovery
Feb 10, 2026
Merged

feat(discovery): transitive inheritance, inherited methods, and bare test support#94
NikkeTryHard merged 1 commit intomasterfrom
fix/class-inheritance-discovery

Conversation

@NikkeTryHard
Copy link
Owner

@NikkeTryHard NikkeTryHard commented Feb 10, 2026

Summary

  • Two-phase discovery: Phase 1 collects ClassInfo for all classes during AST parsing, Phase 2 resolves transitive inheritance and propagates inherited test methods via fixed-point iteration
  • Transitive TestCase detection: BaseLoader(TestCase)CustomLoader(BaseLoader) now correctly discovered
  • Inherited method propagation: StatReloaderTests(ReloaderTests) with empty body inherits all parent test methods
  • Bare test method name matches alongside test_* (4 locations)
  • Same-file class preferred for ambiguous base class resolution
  • 20 new unit tests + 4 integration tests, 873/873 passing

Fixes #86

Summary by CodeRabbit

  • Tests
    • Expanded test discovery to properly detect inherited test methods across class hierarchies
    • Enhanced validation for transitive and cross-file inheritance patterns in test resolution
    • Added comprehensive testing for multi-level inheritance scenarios

…test support

Two-phase discovery pipeline: Phase 1 collects ClassInfo for all classes
during AST parsing, Phase 2 resolves transitive inheritance and propagates
inherited test methods across files using fixed-point iteration.

- Transitive TestCase detection via class hierarchy walk
- Inherited test methods injected into child classes (skips overrides)
- Bare 'test' method name now matches alongside 'test_*'
- Same-file class preferred for ambiguous base class resolution
- 20 new unit tests + 4 integration tests

Fixes #86

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
@NikkeTryHard NikkeTryHard merged commit 35655ae into master Feb 10, 2026
1 check passed
@NikkeTryHard NikkeTryHard deleted the fix/class-inheritance-discovery branch February 10, 2026 04:49
@coderabbitai
Copy link

coderabbitai bot commented Feb 10, 2026

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Walkthrough

The changes implement transitive class inheritance resolution for test discovery. A new inheritance module is introduced with ClassInfo and resolution functions. TestModule now includes a class_defs field. The scanner extracts class metadata during module parsing, and discovery orchestrates cross-file inheritance resolution to uncover tests inherited through class hierarchies.

Changes

Cohort / File(s) Summary
Test Module Updates
rust_tests/cli_integration.rs, rust_tests/resolver_integration.rs, rust_tests/tagging_integrity.rs, rust_tests/toxicity_integration.rs
Added class_defs: vec![] field initialization to TestModule struct instances in test fixtures and mock data.
Discovery Integration Tests
rust_tests/discovery_integration.rs
New integration tests validating transitive and cross-file inheritance discovery, inherited test methods, bare test method names, and multi-level inheritance scenarios.
Inheritance Resolution Module
src/discovery/inheritance.rs
New module implementing transitive class inheritance resolution with ClassInfo struct, two-phase fixed-point algorithm for inheritance propagation, and test-class promotion. Includes unit tests for transitive promotion, method inheritance, and override avoidance.
Discovery Module Exports
src/discovery/mod.rs
Added public module export for the new inheritance module.
Core Discovery Logic
src/discovery/resolver.rs, src/discovery/scanner.rs
Added class_defs field to TestModule. Updated scanner to extract class metadata (bases, methods, decorators, markers) during module parsing. Discovery phase now aggregates ClassInfo across modules and applies resolved inheritance, pruning modules with no remaining tests after resolution.

Sequence Diagram

sequenceDiagram
    participant Scanner
    participant ClassInfo Collection
    participant Resolver
    participant Apply
    participant TestModule
    
    Scanner->>ClassInfo Collection: Extract class metadata (bases, methods, markers, line_number)
    ClassInfo Collection->>ClassInfo Collection: Accumulate ClassInfo across all modules
    ClassInfo Collection->>Resolver: Pass all ClassInfo instances
    Resolver->>Resolver: Phase 1: Propagate is_test_class via transitive inheritance
    Resolver->>Resolver: Phase 2: Propagate inherited test methods through hierarchy
    Resolver->>Apply: Return resolved ClassInfo with inherited methods
    Apply->>TestModule: Inject resolved methods into each module's tests
    Apply->>TestModule: Prune modules with no tests/fixtures/hooks
    TestModule->>TestModule: Final discovery results ready
Loading

Estimated Code Review Effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Suggested Labels

core

Poem

🐰 Through class hierarchies we now descend,
Finding tests in inheritance's blend,
Transitive chains no longer hide,
As borrowed methods come inside,
Discovery hops with newfound pride!

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/class-inheritance-discovery

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Test discovery misses classes with transitive TestCase inheritance and inherited test methods

1 participant