nickylin / powermock

Automatically exported from code.google.com/p/powermock
Apache License 2.0
0 stars 0 forks source link

Default mock policies should work with PowerMockito #153

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
should be ported

Original issue reported on code.google.com by johan.ha...@gmail.com on 9 Sep 2009 at 6:44

GoogleCodeExporter commented 9 years ago

Original comment by johan.ha...@gmail.com on 4 Oct 2009 at 11:40

GoogleCodeExporter commented 9 years ago
Issue 323 has been merged into this issue.

Original comment by johan.ha...@gmail.com on 13 Apr 2011 at 8:05

GoogleCodeExporter commented 9 years ago
Hi,
  I would normally do this in a more standard contribution but, since I'm a bit short on time, I thought it could be a good idea to post something here before I get the chance to come back to this.

I made a quick implementation of the sfl4j MockPolicy for Mockito. You'll find 
the code attached to this comment. 

Let me know if you have questions or want me to push this a bit further. I'll 
probably have a bit a free time in the next few weeks. 

Cheers!

Original comment by alexandr...@gmail.com on 9 Oct 2011 at 1:45

Attachments:

GoogleCodeExporter commented 9 years ago
Thanks for the contribution, really appreciated. There's one thing though, if 
you compare to the EasyMock mock policies 
(org.powermock.api.easymock.mockpolicies.Slf4jMockPolicy) they are reflection 
based so that PowerMock doesn't need the dependency to slf4j itself. We could 
solve it by having a provided dependency to slf4j in maven pom though. Don't 
know which alternative that is the best though. What do you think?

Original comment by johan.ha...@gmail.com on 10 Oct 2011 at 6:45

GoogleCodeExporter commented 9 years ago
Thanks for taking the time to check it out. I initially did this for my own 
needs and since I already had a dependency on sfl4j, it make the code clearer 
to not use reflection. However, it's definitely better to avoid adding a 
dependency to sfl4j in the official distribution and make it the responsibility 
of the using project to do it (since it should already having if it's trying to 
mock it in tests). 

I modified it and I'm sending you the updated version. I also changed the name 
since it being in the mockito package should be enough to indicate this applies 
to Mockito and not EasyMock. 

Cheers!

Original comment by alexandr...@gmail.com on 10 Oct 2011 at 12:18

Attachments:

GoogleCodeExporter commented 9 years ago
Thanks! I did some minor changes and I've committed it to trunk. It would be 
great if you could try building PowerMock from trunk (mvn clean install 
-Dmaven.javadoc.skip=true -Dmaven.test.skip=true to speed it up a bit) and see 
if it works.

Original comment by johan.ha...@gmail.com on 10 Oct 2011 at 12:47

GoogleCodeExporter commented 9 years ago
Hi, 
  Thanks for the minor changes, I should have made those while removing the sfl4j dependency. I did build and install the 1.4.11-SNAPSHOT and modified my tests to used the committed version and I can confirm it works fine.

Thank you for your support.
Cheers,

Original comment by alexandr...@gmail.com on 10 Oct 2011 at 5:09

GoogleCodeExporter commented 9 years ago
Great! Thanks for everything.

Original comment by johan.ha...@gmail.com on 10 Oct 2011 at 5:27

GoogleCodeExporter commented 9 years ago
Thank you for your help, I'm happy to have made a small contribution to 
powermock. :)

Original comment by alexandr...@gmail.com on 12 Oct 2011 at 3:58

GoogleCodeExporter commented 9 years ago
You're welcome to help out as much as you like :)

Original comment by johan.ha...@gmail.com on 12 Oct 2011 at 5:19