-
Notifications
You must be signed in to change notification settings - Fork 26.4k
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
Refactor rpc utils test #13214
Refactor rpc utils test #13214
Conversation
Refactoring prevents RpcUtilsTest from creating mocks for invoker and repeating stubs. A method called creatmockinvoker is created. Set the url that needs to be returned as an argument to creatmockinvoker. Create invoker's mock object inside the method and stub it.
… into refactor-RpcUtilsTest
Codecov Report
@@ Coverage Diff @@
## 3.2 #13214 +/- ##
=========================================
Coverage 69.44% 69.45%
Complexity 2 2
=========================================
Files 1649 1649
Lines 68725 68725
Branches 10014 10014
=========================================
+ Hits 47728 47733 +5
+ Misses 16405 16399 -6
- Partials 4592 4593 +1 see 36 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
dubbo-rpc/dubbo-rpc-api/src/test/java/org/apache/dubbo/rpc/support/RpcUtilsTest.java
Outdated
Show resolved
Hide resolved
Co-authored-by: Albumen Kevin <jhq0812@gmail.com>
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.
Also fix in your code
dubbo-rpc/dubbo-rpc-api/src/test/java/org/apache/dubbo/rpc/support/RpcUtilsTest.java
Outdated
Show resolved
Hide resolved
Kudos, SonarCloud Quality Gate passed!
|
What is the purpose of the change
Similarly, to #13153, I noticed that in
RpcUtilsTest
, there is also a duplicate creation of the mock.The
Invoker
was duplicated to create the mock object 10 times, in 10 test cases.I used a similar approach refactoring to increase code readability.
Brief changelog
I refactored the code to introduce two methods:
CreateMockInvoker(URL url)
andCreateMockInvoker()
. I've used these methods in 10 test cases to reduce the repetitive creation of theInvoker
mock.Additional questions.
I also noticed that this pattern appears in different test files for different packages, do you prefer to use shared utility classes or define these methods in each file?
Verifying this change
Checklist