Skip to content

Conversation

@contrueCT
Copy link

@contrueCT contrueCT commented Sep 13, 2025

Ⅰ. Describe what this PR did

This PR corrects JUnit test method access modifiers and annotation usage:

  • Fix @BeforeEach/@AfterEach method visibility in JUnit 5 tests (private → public)
  • Fix @Rule field access modifier in JUnit 4 tests (private → public)
  • Remove inappropriate @Test annotation from utility methods

These changes ensure proper JUnit framework functionality and test execution.

Ⅱ. Does this pull request fix one issue?

Ⅲ. Why don't you add test cases (unit test/integration test)?

Ⅳ. Describe how to verify it

Ⅴ. Special notes for reviews

Copy link
Member

@YongGoose YongGoose left a comment

Choose a reason for hiding this comment

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

Are there similar cases elsewhere?
If so, it would be good to address all of them in this PR.

@codecov
Copy link

codecov bot commented Sep 14, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 62.46%. Comparing base (dc9bf00) to head (4c7bf9d).
⚠️ Report is 2 commits behind head on 2.x.

Additional details and impacted files
@@             Coverage Diff              @@
##                2.x    #7635      +/-   ##
============================================
+ Coverage     62.41%   62.46%   +0.05%     
  Complexity      721      721              
============================================
  Files          1324     1324              
  Lines         50125    50125              
  Branches       5920     5920              
============================================
+ Hits          31285    31313      +28     
+ Misses        16027    16001      -26     
+ Partials       2813     2811       -2     

see 12 files with indirect coverage changes

Impacted file tree graph

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

- Fix @BeforeEach/@AfterEach methods visibility in JUnit 5 tests
- Fix @rule field access modifier from private to public in JUnit 4 tests
- Remove inappropriate @test annotation from utility method
@contrueCT contrueCT requested a review from YongGoose September 14, 2025 15:56
@contrueCT
Copy link
Author

Are there similar cases elsewhere? If so, it would be good to address all of them in this PR.

Thanks for your suggestion! I’ve checked and fixed all similar cases in the test classes. Could you please take another look when you get a chance?

@contrueCT contrueCT changed the title test: fix JUnit 5 lifecycle method visibility test: fix JUnit test method access modifiers and annotations Sep 14, 2025
@YongGoose
Copy link
Member

Thanks for your suggestion! I’ve checked and fixed all similar cases in the test classes. Could you please take another look when you get a chance?

Please use JUnit5 instead of JUnit4.

@contrueCT
Copy link
Author

Done. Replaced all JUnit4 references with JUnit5. Please take another look when you get a chance.

@contrueCT
Copy link
Author

@YongGoose I've updated the PR based on your feedback. Could you please take another look when you have time? Thanks!

@contrueCT
Copy link
Author

The CI failure in the seata-config-zk module only occurs in the Java 8 build and is unrelated to my changes. The same tests pass successfully in Java 17 and Java 21, indicating a compatibility issue between ZooKeeper client and Java 8 in the CI environment—not a code problem.

@contrueCT
Copy link
Author

Hi @YongGoose ,
I've addressed all the feedback you left in your review https://github.com/apache/incubator-seata/pull/7635#issuecomment-3291173245
Could you please take another look when you have a moment?
Thanks a lot! 😊

@slievrly
Copy link
Member

@YongGoose Pls take a look.

YongGoose

This comment was marked as outdated.

Copy link
Member

@YongGoose YongGoose left a comment

Choose a reason for hiding this comment

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

Please apply spotless :)

Once you’ve fixed the Spotless issues, please ping me and I’ll give my approval.

EtcdListener etcdListener = new EtcdListener();
registryService.subscribe(CLUSTER_NAME, etcdListener);
// 3.delete instance,see if the listener can be notified
registryService.subscribe(DEFAULT_TX_GROUP, etcdListener);
Copy link
Member

Choose a reason for hiding this comment

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

Just curious, was there any particular reason for using DEFAULT_TX_GROUP instead of CLUSTER_NAME?

Copy link
Author

Choose a reason for hiding this comment

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

Yes! The subscribe() and lookup() methods expect a transaction service group, not an etcd cluster name.
The original code had mismatched key paths:

  • Registration: registry-seata-<DEFAULT_TX_GROUP>/...
  • Subscription: registry-seata-<CLUSTER_NAME>/...

Even though both values were "default", using DEFAULT_TX_GROUP is semantically correct and matches how Seata actually works - clients look up services by transaction group.

@contrueCT
Copy link
Author

I've fixed the Spotless issues, plaese take a look : ) @YongGoose

Copy link

Copilot AI left a 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 corrects JUnit test method access modifiers and annotation usage to ensure proper test execution. The changes address framework requirements where lifecycle methods and fields must be public rather than private, and remove incorrect @Test annotations from utility methods.

Key Changes:

  • Changed @BeforeEach and @AfterEach annotated methods from private to public visibility
  • Removed @Test annotations from utility/helper methods that are not actual test cases
  • Refactored etcd3 test to use JUnit 5 lifecycle annotations instead of JUnit 4's @Rule

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.

Show a summary per file
File Description
test/src/test/java/org/apache/seata/at/oracle/SupportOracleDataTypeTest.java Removed @Test annotation from testTypeSql utility method
test/src/test/java/org/apache/seata/at/ATModeSupportDataBaseDataTypeTest.java Removed @Test annotation from helper method and fixed method call bugs
server/src/test/java/org/apache/seata/server/ParameterParserTest.java Changed @BeforeEach method from private to public
rm-datasource/src/test/java/org/apache/seata/rm/datasource/undo/BaseH2Test.java Changed @BeforeEach method from private to public
discovery/seata-discovery-etcd3/src/test/java/org/apache/seata/discovery/registry/etcd3/EtcdRegistryServiceImplTest.java Migrated from JUnit 4 @Rule to JUnit 5 lifecycle methods with proper setup/teardown
discovery/seata-discovery-etcd3/pom.xml Added mockito-core test dependency
changes/zh-cn/2.x.md Added changelog entry in Chinese
changes/en-us/2.x.md Added changelog entry in English

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link
Member

@YongGoose YongGoose left a comment

Choose a reason for hiding this comment

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

LGTM

@YongGoose YongGoose requested a review from funky-eyes October 27, 2025 14:20
@YongGoose
Copy link
Member

@funky-eyes

I think this pr can be merged now :)

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.

5 participants