rysang / mockito

Automatically exported from code.google.com/p/mockito
0 stars 0 forks source link

Enhancement add throw exception to Answer #411

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
cannot specify throw exception on Mock annotation

What is the expected output? What do you see instead?

What version of the product are you using? On what operating system?
mokito-core 1.9.5

Please provide any additional information below.

add  THROW_EXCEPTION(new ThrowUnsupportedOperationExceptionAnswer()) to 
org.mockito.Answers

my implementation don't call toString() on mock to avoid nested exception

Original issue reported on code.google.com by filippo....@gmail.com on 16 Jan 2013 at 6:18

Attachments:

GoogleCodeExporter commented 8 years ago
Hi,

Thanks for sharing your ideas :)
I'm personally not favorable to that for the simple reason that this 
implementation is a custom behavior for throwing exceptions, plus I don't see 
how it'll benefit many users.

I understand though that default answer for mock annotation is a bit of an 
issue as annotations in Java don't allow live instances for values, which is an 
issue if we want to add custom answer. But I'd rather define the mock using 
Mockito.mock(type, withSettings.defaultAnswer(the answer)), that offer more 
flexibility that annotations.

Anyway that'll depend on how the rest of the team feels about it.

Original comment by brice.du...@gmail.com on 16 Jan 2013 at 7:17

GoogleCodeExporter commented 8 years ago

Original comment by brice.du...@gmail.com on 16 Jan 2013 at 7:17

GoogleCodeExporter commented 8 years ago

Original comment by brice.du...@gmail.com on 29 Apr 2013 at 4:10