How to verify method return with Mockito ?

165 views
Skip to first unread message

Artjom.Kalita

unread,
Mar 7, 2011, 9:58:43 AM3/7/11
to Java User Group Latvia
Hello, have some question about Mockito usage. I have a method -
getSomethingAmount() in some class (class A) I want to test. This
getSomethingAmount() method logic depends on Set<B> bSet, which is
passed in constructor on class A initialization. For example if
Set<B> bSet contains of 2 elements, when getSomethingAmount() must
return 2 elements. How can I correctly verify this condition with
Mockito ?

P.S. Now I stub 2 B class elements put them into bSet and then assert
getSomethingAmount() method result with junit assertion - it works,
but it doesn't looks to time like "true" Mockito way.

Jānis Ābele

unread,
Mar 8, 2011, 6:05:15 AM3/8/11
to jug-l...@googlegroups.com
You could mock whole bSet and verify interaction with it.
Reply all
Reply to author
Forward
0 new messages