-
Notifications
You must be signed in to change notification settings - Fork 8.9k
test: add UT for org.apache.seata.spring.annotation.scannercheckers #7423
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds unit tests for the scanner checkers in the seata spring module to ensure that bean scope and package scanning validations behave as expected.
- Adds tests for ScopeBeansScannerChecker covering scenarios with null bean factory, non-annotated bean definitions, and various scope exclusions.
- Adds tests for PackageScannerChecker to verify package matching behaviors and case sensitivity.
- Adds tests for ConfigBeansScannerChecker to validate bean name patterns for configuration classes.
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| spring/src/test/java/org/apache/seata/spring/annotation/scannercheckers/ScopeBeansScannerCheckerTest.java | Unit tests to verify scope exclusion logic and helper methods using reflection |
| spring/src/test/java/org/apache/seata/spring/annotation/scannercheckers/PackageScannerCheckerTest.java | Unit tests covering package scanning and case sensitivity checks |
| spring/src/test/java/org/apache/seata/spring/annotation/scannercheckers/ConfigBeansScannerCheckerTest.java | Parameterized tests and specific cases for validating configuration bean naming |
| * Helper method to get the EXCLUDE_SCOPE_SET field value | ||
| */ | ||
| @SuppressWarnings("unchecked") | ||
| private Set<String> getExcludeScopeSet() throws Exception { |
Copilot
AI
Jun 8, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider refactoring the reflection-based helper methods into a common test utility to reduce code duplication and improve maintainability.
| * Helper method to get the SCANNABLE_PACKAGE_SET field value | ||
| */ | ||
| @SuppressWarnings("unchecked") | ||
| private Set<String> getScannablePackageSet() throws Exception { |
Copilot
AI
Jun 8, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider extracting the reflection-based helper methods for field access into a shared utility class for improved maintainability and to reduce duplication across test files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but not necessary
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## 2.x #7423 +/- ##
============================================
+ Coverage 59.10% 59.24% +0.13%
Complexity 531 531
============================================
Files 1281 1281
Lines 46142 46142
Branches 5561 5561
============================================
+ Hits 27271 27335 +64
+ Misses 16302 16232 -70
- Partials 2569 2575 +6 🚀 New features to boost your workflow:
|
slievrly
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Ⅰ. Describe what this PR did
Ⅱ. Does this pull request fix one issue?
fixes #7377
Ⅲ. Why don't you add test cases (unit test/integration test)?
Ⅳ. Describe how to verify it
Ⅴ. Special notes for reviews