dhamini-poornachandra / mockito

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

Mocking behaviour on two mocks at the same time causes exception, but message is unclear. #444

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
calling:
when(foo.bar()).thenReturn(createMockReturning("something"))

where createMockReturning is defined as:
public Something createMockReturning(final String value) {
  final Something mockSomething = mock(Something.class); 
  when(something.value()).thenReturn(value);
  return mockSomething;
}

The exception thrown if you try and do this hints that there is unfinished 
stubbing (i.e. you haven't coded the thenReturn); or that the method/class was 
final.  This isn't the situation here, instead you've just tried recording two 
mocks at the same time.  This isn't entirely clear unless you know how the 
internals of the recording occurs.

Mockito 1.9.0

It would be good to just add this as another hint, e.g. "Hint 3: are you trying 
to mock behaviour on two mocks at the same time?"

Original issue reported on code.google.com by Christop...@gmail.com on 19 Jul 2013 at 2:29

GoogleCodeExporter commented 8 years ago

Original comment by brice.du...@gmail.com on 4 Dec 2013 at 1:32

GoogleCodeExporter commented 8 years ago
Thx for the idea, you could also make a pull request ;)

Original comment by brice.du...@gmail.com on 4 Dec 2013 at 1:32

GoogleCodeExporter commented 8 years ago
Hi, I just checked the latest sources, this doesn't look fixed even though this 
is marked as fixed?
Should I create a pull request for this still?

Original comment by Christop...@gmail.com on 23 Feb 2014 at 11:32

GoogleCodeExporter commented 8 years ago

Original comment by szcze...@gmail.com on 16 Aug 2014 at 2:43

GoogleCodeExporter commented 8 years ago

Original comment by szcze...@gmail.com on 24 Aug 2014 at 3:14

GoogleCodeExporter commented 8 years ago

Original comment by szcze...@gmail.com on 24 Aug 2014 at 3:50

GoogleCodeExporter commented 8 years ago

Original comment by szcze...@gmail.com on 24 Aug 2014 at 4:17