Error: Cannot invoke thenReturn(boolean) on the primitive type boolean

13,653 views
Skip to first unread message

Twinkie

unread,
Mar 20, 2012, 1:18:41 PM3/20/12
to mockito
I get this weird error when using a thenReturn.

Error:
Cannot invoke thenReturn(boolean) on the primitive type boolean

Line that causes this compiler error:
when(mockMyClass.myMethod(anyString()).thenReturn(true));

The method signature is:
boolean myMethod (String param);

Would anyone know the reason?

Thanks,
Twinkie

jordi

unread,
Mar 20, 2012, 1:25:49 PM3/20/12
to moc...@googlegroups.com
you got your parentheses wrong:

when(mockMyClass.myMethod(anyString())).thenReturn(true);

hth,
jordi


--
You received this message because you are subscribed to the Google Groups "mockito" group.
To post to this group, send email to moc...@googlegroups.com.
To unsubscribe from this group, send email to mockito+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/mockito?hl=en.


Brice Dutheil

unread,
Mar 20, 2012, 1:27:37 PM3/20/12
to moc...@googlegroups.com
Hi,

Could you make sure the language level is at least 1.5+ in your IDE.

-- Brice

-- 
Brice Dutheil

Brice Dutheil

unread,
Mar 20, 2012, 1:28:32 PM3/20/12
to moc...@googlegroups.com
Well even better, thx Jordi ;)

-- 
Brice Dutheil

Twinkie

unread,
Mar 20, 2012, 1:54:08 PM3/20/12
to mockito
Duh! Got it right now.

Thanks much :-)

Twinkie
> >http://groups.google.com/group/mockito?hl=en.- Hide quoted text -
>
> - Show quoted text -
Reply all
Reply to author
Forward
0 new messages