Mockito Mock on Static method of called class from calling class method
posted 2 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Hi All,
I have processPaymentDetails method like below for which trying to write unit test using mockito. Since PaymentAdapter class has static method parsePaymentInformatin getting called directly on class name without autowire not sure if i can use Mock for PaymentAdapter
Can you please advise. Any good links to refer these mockito related examples, concepts?
I have processPaymentDetails method like below for which trying to write unit test using mockito. Since PaymentAdapter class has static method parsePaymentInformatin getting called directly on class name without autowire not sure if i can use Mock for PaymentAdapter
Can you please advise. Any good links to refer these mockito related examples, concepts?
posted 2 years ago
-
1 -
-
Number of slices to send:Optional 'thank-you' note:
-
-
From Mockito 3.4.0, it is possible to mock static methods
https://www.baeldung.com/mockito-mock-static-methods
https://www.baeldung.com/mockito-mock-static-methods
Bhaskar Bantupalli
posted 2 years ago
Why do you want to mock it in the first place?
Every time I see such variables names (in this case parameters), I freak out. What is the rationale behind naming pmtSt and not payment then pmtType and not paymentType? PmtSt type is also cryptic which very likely makes all code cryptic.
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
sai rama krishna wrote:Since PaymentAdapter class has static method parsePaymentInformatin getting called directly on class name without autowire not sure if i can use Mock for PaymentAdapter
Why do you want to mock it in the first place?
sai rama krishna wrote:
Every time I see such variables names (in this case parameters), I freak out. What is the rationale behind naming pmtSt and not payment then pmtType and not paymentType? PmtSt type is also cryptic which very likely makes all code cryptic.
posted 2 years ago
Here is another one.. Please, try to be disciplined, if that's not you, try to champion such values in the team, so code would be better readable. That is very important!
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
sai rama krishna wrote:
Here is another one.. Please, try to be disciplined, if that's not you, try to champion such values in the team, so code would be better readable. That is very important!
sai rama krishna
Ranch Hand
Posts: 1029
2
posted 2 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Thank you. I some time use mock for inject mock and vice versa and try to use mock where not needed. Any good books or resources to make my unit testing especially mockito concepts more deeper, stronger.
| For my next feat, I will require a volunteer from the audience! Perhaps this tiny ad? The new gardening playing cards kickstarter is now live! https://www.kickstarter.com/projects/paulwheaton/garden-cards |








