-
Notifications
You must be signed in to change notification settings - Fork 8.9k
test: add UT for seata-spring-boot-starter module #7422
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
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## 2.x #7422 +/- ##
============================================
+ Coverage 59.36% 59.43% +0.07%
- Complexity 531 543 +12
============================================
Files 1281 1281
Lines 46142 46142
Branches 5561 5561
============================================
+ Hits 27390 27426 +36
+ Misses 16188 16149 -39
- Partials 2564 2567 +3 🚀 New features to boost your workflow:
|
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 seata-spring-boot-starter module to verify conditional bean registration across several auto-configuration classes, updates the POM to include necessary test dependencies, and logs the new tests in the changelogs.
- Introduces new test classes for Saga, HTTP, DataSource, and core auto-configuration.
- Updates
pom.xmlwith Spring Boot test and servlet API dependencies. - Updates changelogs to record the addition of these tests.
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| seata-spring-boot-starter/src/test/java/.../SeataSagaAutoConfigurationTest.java | Adds tests for saga auto-configuration and async executor beans |
| seata-spring-boot-starter/src/test/java/.../SeataHttpAutoConfigurationTest.java | Adds tests for HTTP auto-configuration under various scenarios |
| seata-spring-boot-starter/src/test/java/.../SeataDataSourceAutoConfigurationTest.java | Adds tests for data source auto-configuration with properties |
| seata-spring-boot-starter/src/test/java/.../SeataAutoConfigurationTest.java | Adds tests for core auto-configuration components |
| seata-spring-boot-starter/pom.xml | Adds test dependencies (spring-boot-test, servlet APIs) |
| changes/zh-cn/2.x.md, changes/en-us/2.x.md | Records the addition of these unit tests |
Comments suppressed due to low confidence (3)
seata-spring-boot-starter/src/test/java/org/apache/seata/spring/boot/autoconfigure/SeataSagaAutoConfigurationTest.java:134
- Consider adding a negative test case to verify that the async executor and rejected handler beans are not created when
seata.saga.state-machine.enable-asyncis false, improving coverage for the disabled scenario.
assertThat(rejectedExecutionHandler).isInstanceOf(ThreadPoolExecutor.CallerRunsPolicy.class);
changes/en-us/2.x.md:83
- [nitpick] Use 'unit tests' instead of 'UT' for clarity in the changelog entry.
- [[#7422](https://github.com/apache/incubator-seata/pull/7422)] add UT for seata-spring-boot-starter module
seata-spring-boot-starter/pom.xml:81
- [nitpick] Including both
jakarta.servlet-apiandjavax.servlet-apican cause classpath conflicts; consider consolidating to only the required servlet API dependency for tests.
<artifactId>jakarta.servlet-api</artifactId>
|
|
||
| import static org.apache.seata.spring.boot.autoconfigure.SeataSagaAutoConfiguration.SAGA_ASYNC_THREAD_POOL_EXECUTOR_BEAN_NAME; | ||
| import static org.apache.seata.spring.boot.autoconfigure.SeataSagaAutoConfiguration.SAGA_REJECTED_EXECUTION_HANDLER_BEAN_NAME; | ||
| import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat; |
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.
[nitpick] Mixed use of AssertionsForClassTypes.assertThat and AssertionsForInterfaceTypes.assertThat imports may confuse readers; consider unifying to a single assertion style for consistency.
| "seata.enableAutoDataSourceProxy=true", | ||
| "seata.enable-auto-data-source-proxy=true" |
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.
[nitpick] The test includes both camelCase and kebab-case property keys; it would be clearer to test only the actual property name supported by SeataProperties, reducing redundancy.
| "seata.enableAutoDataSourceProxy=true", | |
| "seata.enable-auto-data-source-proxy=true" | |
| "seata.enableAutoDataSourceProxy=true" |
| * Tests for {@link SeataHttpAutoConfiguration} to verify conditional bean registration. | ||
| */ | ||
| public class SeataHttpAutoConfigurationTest { | ||
| // No thread safety issues, no need to create in @BeforeEach |
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.
[nitpick] This comment about thread safety and @BeforeEach maintenance can be removed to reduce noise, as the test runner is inherently single-threaded by default.
| // No thread safety issues, no need to create in @BeforeEach |
|
@OmCheeLin thanks for your contribution. |
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
add UT for seata-spring-boot-starter module
Ⅱ. Does this pull request fix one issue?
fixes #7381
Ⅲ. Why don't you add test cases (unit test/integration test)?
Ⅳ. Describe how to verify it
Ⅴ. Special notes for reviews