Repository navigation
[Tests] Fix flaky WrongTypeOfReturnValue Mockito misuse issue in broker tests - #13621
Conversation
…lue issue in broker tests - replace spying of a instance with a spy created by Mockito with given constructor arguments
52048fe to
e9b4816
Compare
|
This is to also fix issues like this: This problem persisted after making #13608 change. |
|
@lhotari I have tried to cherry-pick this PR into branch-2.8, but there are many conflicts with branch-2.8. Do you want to push a PR to branch-2.8 directly? |
@codelipenghui I can deal with it next week. |
|
Thanks @lhotari |
@lhotari I still can get this flaky test. https://github.com/apache/pulsar/runs/4976572806?check_suite_focus=true |
|
@gaozhangmin thanks, I'll reopen #13620 |
|
@lhotari - since we're still observing test failures, is it worth cherry-picking this to 2.8? There are many conflicts when I just attempted to cherry-pick this commit. |
|
Same as @michaeljmarshall mentioned, I move this PR to |
Fixes #13620
Motivation
Mockito spy creation fails sporadically and causes an exception and Mockito misuse warning:
example failure
Additional context
The exception message gives this hint:
the
doReturnfamily of methods is already used so it must be some other problem.The assumption of the solution in this PR is that when an instance spy is replaced with a mock that internally creates the spy instance using the given class and constructor arguments would solve the issue.
Modifications
spyWithClassAndConstructorArgs