easyforgood / mockito

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

Make it possible to change the MockUtil #371

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
When developing PowerMock it sometimes require a great deal of work and hacks 
in order to integrate with Mocktio. One of the reasons is because of the 
PrintSettings class because when the print method is called it uses the the 
MockUtil to get the name of the mock. The problem for PowerMock is that the 
call to getMockName throws a NotAMockException because the mock (in cases of 
static methods) are not handled by Mockito. If it would somehow be possible to 
change the MockUtil implementation it would make the life much easier for me as 
a PowerMock developer.

Original issue reported on code.google.com by johan.ha...@gmail.com on 31 Aug 2012 at 2:47

GoogleCodeExporter commented 8 years ago
Hi Johan,

Interesting suggestion. MockUtil is still internal stuff.

Also did you tried the new mockmaker approach ? MockUtil has been refactored to 
delegate a lot of work to the MockMaker.

Cheers,
Brice

Original comment by brice.du...@gmail.com on 31 Aug 2012 at 2:57

GoogleCodeExporter commented 8 years ago
No I haven't tried it, but it looks very interesting. I'll look into it. Thanks 
for the tip.

Original comment by johan.ha...@gmail.com on 31 Aug 2012 at 3:28

GoogleCodeExporter commented 8 years ago
I think I've made some progress using the MockMaker SPI but it seems like the 
MockHandler implementation created by the MockMaker must return an instance of 
InternalMockHandler.

Original comment by johan.ha...@gmail.com on 31 Aug 2012 at 3:54

GoogleCodeExporter commented 8 years ago

Original comment by brice.du...@gmail.com on 3 Sep 2012 at 9:56

GoogleCodeExporter commented 8 years ago
Johan, you're right you cannot replace MockHandler implementation at this time. 
Can you tell me a little bit more what are the biggest pain points? Mockito was 
not developed for embedded usage but we're working on making things better :)

I'll think about this use case and figure something out.

Original comment by szcze...@gmail.com on 19 Sep 2012 at 7:10

GoogleCodeExporter commented 8 years ago
I've looked at Powermock code and indeed it looks like you needed to do a lot 
of creative hackery to wrap Mockito :)

Regarding MockUtil, I'm tempted to relax the way name is obtained, so that if 
something is not a mock, we'll return a default name.

Down the road, we need to finish externalizing the MockHandler interface. This 
way it should be possible to provide custom implementation of the MockHandler.

Johan feel free to lay out your requirements regarding the api so that we can 
make embedding Mockito a better experience.

Original comment by szcze...@gmail.com on 19 Sep 2012 at 9:13