Wei-Chiu Chuang created HDDS-12472:
--------------------------------------

             Summary: Use Mockito doReturn whenever possible
                 Key: HDDS-12472
                 URL: https://issues.apache.org/jira/browse/HDDS-12472
             Project: Apache Ozone
          Issue Type: Bug
            Reporter: Wei-Chiu Chuang


We are not use Mockito to stub method correctly.

A lot of places we write in this pattern: when(xxx.yyy()).thenReturn(zzz), when 
it's less error-prone to write in doReturn(zzz).when(xxx).yyy();

https://wesalvaro.medium.com/mockitos-sinister-silent-stub-secret-eeef5e5f6ec1 
here is one example where using it incorrectly throws weird exceptions. I 
encountered one in TestOMKeyRequest because of the spy object omSnapshotManager.


Also check out 
https://stackoverflow.com/questions/20353846/mockito-difference-between-doreturn-and-when



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to