Skip to content

Comments

fix(discovery): suffix + inheritance-based test class matching#87

Merged
NikkeTryHard merged 5 commits intomasterfrom
fix/issue-80-test-class-discovery
Feb 10, 2026
Merged

fix(discovery): suffix + inheritance-based test class matching#87
NikkeTryHard merged 5 commits intomasterfrom
fix/issue-80-test-class-discovery

Conversation

@NikkeTryHard
Copy link
Owner

@NikkeTryHard NikkeTryHard commented Feb 10, 2026

Summary

  • Add is_test_class() helper matching Test* prefix, *Test, *Tests, and *TestCase suffixes
  • Add has_testcase_base() to inspect AST base classes for direct TestCase inheritance
  • Simplify resolver fixture lookup — remove redundant name filter
  • Fix pre-existing deprecated criterion::black_box in bench files

Closes #80

Results

Metric Before After
Django tests discovered ~1,043 9,237
Unique test classes ~134 1,113
Unit tests 849 854

Verified in Docker: cargo buildcargo fmtcargo clippy -D warnings854/854 tests pass

Follow-up

Remaining gaps (transitive inheritance, inherited methods) tracked in #86.

Summary by CodeRabbit

  • New Features

    • Enhanced test discovery for Python projects to recognize more test class patterns, including suffix-based naming conventions (Test/Tests) and inheritance from TestCase-based frameworks.
  • Performance Improvements

    • Increased test execution parallelism for faster results.
    • Optimized Docker builds with pre-built binaries and persistent caching to accelerate container rebuilds.

- Bump cargo jobs and test threads from 4 to 8
- Cap nextest threads at 8 for predictable runs
- Switch Dockerfile sccache/nextest to pre-built binaries
- Add cargo-target volume for persistent build cache
Add is_test_class() to match classes ending with Test, Tests, or TestCase
alongside the existing starts_with("Test") prefix check. Add
has_testcase_base() to inspect AST base classes for TestCase inheritance.

Update scanner to use both name matching and base class inspection.
Simplify resolver fixture lookup — remove redundant name filter since
scanner already validates classes at discovery time.

Closes #80
…covery

Cover suffix-based class names (LoginTest, ModelFormTests), TestCase
suffix (AutodiscoverModulesTestCase), async methods in suffix classes,
unittest.TestCase base class detection, and comprehensive edge cases
(Contest, Fastest, Tes, etc.).
@NikkeTryHard NikkeTryHard merged commit 4dc0631 into master Feb 10, 2026
1 check passed
@NikkeTryHard NikkeTryHard deleted the fix/issue-80-test-class-discovery branch February 10, 2026 02:40
@coderabbitai
Copy link

coderabbitai bot commented Feb 10, 2026

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Walkthrough

This PR increases build parallelism (jobs and test threads from 4 to 8), optimizes Docker builds by downloading pre-built binaries instead of building from source, refactors benchmark code to use standard library imports directly, adds persistent cargo volume in Docker Compose, and enhances Python test discovery to recognize test classes by multiple naming conventions (suffix-based matching) and base-class inheritance patterns.

Changes

Cohort / File(s) Summary
Build & Parallelism Configuration
.cargo/config.toml, .config/nextest.toml
Increased parallelism limits: jobs/test-threads changed from 4 to 8. Nextest config updated to use numeric value 8 instead of "num-cpus" string.
Docker Optimization
Dockerfile
Replaced cargo install builds with pre-built binary downloads: sccache v0.10.0 and latest nextest Linux binary, extracted directly to /usr/local/bin.
Benchmark Imports
benches/hot_paths.rs, benches/plugin_overhead.rs
Removed import alias for black_box; switched to direct std::hint::black_box usage.
Docker Compose Volume
docker-compose.yml
Added named cargo-target volume and mounted it to /workspace/target for build cache persistence across container rebuilds.
Test Discovery Logic
src/discovery/mod.rs, src/discovery/resolver.rs, src/discovery/scanner.rs
Added is_test_class() and has_testcase_base() utilities. Expanded class detection from prefix-only ("Test*") to support suffix matching ("Test", "Tests") and base-class inheritance (unittest.TestCase, Django patterns). Relaxed class-scoped fixture lookup to remove "Test" prefix requirement. Added 199 lines of comprehensive unit tests covering suffix-based discovery, inheritance patterns, parametrized tests, async tests, and edge cases.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related issues

Suggested labels

discovery, tests, rust, ci

Poem

🐰 A discovery so bright and keen,
Now matches names we've never seen!
From "Tests" that end to bases deep,
More hidden tests our burrow shall keep!

✨ 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/issue-80-test-class-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.

fix(discovery): expand class name filter to match Django/unittest naming conventions

1 participant