enhance unit test#2920
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2920 +/- ##
==========================================
+ Coverage 63.71% 63.83% +0.11%
==========================================
Files 578 578
Lines 25928 25928
Branches 4539 4539
==========================================
+ Hits 16521 16552 +31
+ Misses 7235 7206 -29
+ Partials 2172 2170 -2
Continue to review full report at Codecov.
|
| public void test_Notified_withGroupFilter() { | ||
| URL directoryUrl = noMeaningUrl.addParameterAndEncoded(Constants.REFER_KEY, "interface" + service + "&group=group1,group2"); | ||
| RegistryDirectory directory = this.getRegistryDirectory(directoryUrl); | ||
| URL provider1 = URL.valueOf("dubbo://10.134.108.1:20880?methods=getXXX&group=group1&mock=false"); |
There was a problem hiding this comment.
Do you feel it below mention way could be a better approach
URL provider1=URL.valueOf("dubbo://10.134.108.1:20880")
.addParameter("methods", "getXXX")
.addParameter("group", "group1")
.addParameter("mock","false");
This might give better readability and might prevent accidental mistake of placing url escape character.
There was a problem hiding this comment.
Your approach is clear, but I think the simpler the code, the better.
...bo-registry-default/src/test/java/org/apache/dubbo/registry/dubbo/RegistryDirectoryTest.java
Show resolved
Hide resolved
| Assert.assertTrue(invokers.get(0) instanceof MockClusterInvoker); | ||
| Assert.assertTrue(invokers.get(1) instanceof MockClusterInvoker); | ||
|
|
||
| directoryUrl = noMeaningUrl.addParameterAndEncoded(Constants.REFER_KEY, "interface" + service + "&group=group1"); |
There was a problem hiding this comment.
group1 can be also defined a variable so that it can be reuse here, so in future even we change value of it, it would be a single place change only.
There was a problem hiding this comment.
I appreciate your spirit of code refinement, we should code with specification,and I also found that some unit tests were not written in strict accordance with the code specification,I wonder if we have any hard and fast rules for coding unit tests @carryxyh
There was a problem hiding this comment.
@lixiaojiee Would you please bring your question to the dev mailing list, we can discuss it there. For now, it looks good to me. I will merge it.
|
LGTM, thanks for the pull request! |
* added dubbo-rpc-api filter documentation for issue no #2935 * wrong @see java.io.File was added, removed this version of checkins * Close all ports after tests finish (#2906) * fix testCustomExecutor (#2904) * Graceful shutdown enhancement in Spring (#2901) * Simplify the code logic of the method AbstractClusterInvoker#reselect. (#2826) * Simplify the code logic of the method AbstractClusterInvoker#reselect. * Minor modification for code style. * create AbstractRouter (#2909) * create AbstractRouter * router default method * router default method * router default method * mockinvoker * Added javadoc for dubbo-filter module dubbo github issue 2884 (#2921) * Enhance unit test (#2920) * Change Readme dubbo-sample hyperlink (#2927) * Simply TagRouter (#2924) * make telnet config work again (#2925) * Remove the log to putRandomPort when one protocol use random port (#2931) * optimize findConfigedPorts method of ServiceConfig to log only one time when userandom port * move the log to method putRandomPort * Fix DubboShutdownHook Memory Leak (#2922) * Improve UT grammar and remove unnecessary braces. (#2930) * Improve UT grammer, fix compiler warnings. * Remove unnecessary braces. * re-enable testCustomExecutor (#2917) * fix testCustomExecutor * fix ci * Fixing test-order dependency for FstObjectInputTest (#2815) * re-enable testCustomExecutor (#2913) * Resetting ExtensionLoader to remove test order dependencies in StickyTest (#2807) * optimize the RondRobinLoadBalance and MockClusterInvoker (#2932) delete unused logic and take the logger out. * [Dubbo-2864] Fix build failed with -Prelease (#2923) fixes #2864 * Fix telnet can not find method with enum type (#2803) * [dubbo-2766] fix the bug of isMatch method of InvokeTelnetHandler (#2787) * enhance org.apache.dubbo.rpc.protocol.dubbo.telnet.InvokeTelnetHandler#isMatch (#2941) * enhance isMatch * remove useless imports * [Dubbo-2766]Fix 2766 and enhance the invoke command (#2801) * add getter and setter for ServiceConfig's interfaceName property#2353 * add interfaceName to ignoreAttributeNames and change the unit test * delete the demo source code and update the unit test * unchange ServiceConfig * update unit test * update unit test * fix #2798 and enhance invoke command * Delete useless assignments (#2939) * Replace anonymous class with method reference (#2929) * Replace anonymous class with method reference * Revert changes as per @beiwei30 code review * Optimize retry for FailbackRegistry. (#2763) * Abstract retry task * Task for retry. * Fix sth. * Finish Optimize. fix ci failed. * Optimize retry for FailbackRegistry. The retry operation splits into specific operations, such as subscriptions and registrations. This approach allows for very precise retry control. * Optimize retry for FailbackRegistry. The retry operation splits into specific operations, such as subscriptions and registrations. This approach allows for very precise retry control. * Optimize logger warn's msg. * Optimize FailedNotifiedTask's run method. Optimize addXXXTask, directly return if we already have a retry task. * Optimize notify logic, just notify when the urls is not empty. * Optimize notify logic, just notify when the urls is not empty. * Optimize timer that use daemon thread. * standardize semantics of all mergers,enhance mergeFactory and testcase (#2936) * Modified to lower camel case (#2945) * Improve several map iteration (#2938) * added dubbo-rpc-api filter documentation for issue no #2935 * wrong @see java.io.File was added, removed this version of checkins
What is the purpose of the change
add RegistryDIrectory UT
Brief changelog
/dubbo-registry-default/src/test/java/org/apache/dubbo/registry/dubbo/RegistryDirectoryTest.java
Verifying this change
UT pass
Follow this checklist to help us incorporate your contribution quickly and easily:
[Dubbo-XXX] Fix UnknownException when host config not exist #XXX. Each commit in the pull request should have a meaningful subject line and body.mvn clean install -DskipTests&mvn clean test-compile failsafe:integration-testto make sure unit-test and integration-test pass.