ahmaddarawshi / powermock

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

createPartialMock should support mocking overridden methods in super classes #51

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
If A extends B and both have a method called "mockMe" (A overrides B's
mockMe method) you should be able to specify where in the class hierarchy
the method should be mocked. 

Original issue reported on code.google.com by johan.ha...@gmail.com on 29 Oct 2008 at 11:45

GoogleCodeExporter commented 9 years ago

Original comment by johan.ha...@gmail.com on 29 Oct 2008 at 11:45

GoogleCodeExporter commented 9 years ago

Original comment by johan.ha...@gmail.com on 31 Oct 2008 at 8:02

GoogleCodeExporter commented 9 years ago
Moved to future release

Original comment by johan.ha...@gmail.com on 17 Nov 2008 at 12:30

GoogleCodeExporter commented 9 years ago
Do you know in which future release?

Original comment by magnus.p...@gmail.com on 8 May 2009 at 7:57

GoogleCodeExporter commented 9 years ago
Unfortunately not. I've tried to solve this before but I was unable to do so. 
But now
since it's a requested feature maybe we'll prioritize it a bit more.

Original comment by johan.ha...@gmail.com on 8 May 2009 at 10:49

GoogleCodeExporter commented 9 years ago
suppressMethod should also support this

Original comment by johan.ha...@gmail.com on 11 May 2009 at 6:23

GoogleCodeExporter commented 9 years ago
supress method doesnt support this in case the the superclass method is called 
within
the subclass method that is overiding it. for instance super.xxx()

Original comment by rani....@gmail.com on 11 Jun 2009 at 10:35

GoogleCodeExporter commented 9 years ago
Yes we're aware of this as well

Original comment by johan.ha...@gmail.com on 11 Jun 2009 at 10:39

GoogleCodeExporter commented 9 years ago
So is there any way i can run the test case for a method that overides and 
calls the
super class method in it?Is there anyway to get rid of the error when the
line..super.xxx() gets called within the method that is tested?

Original comment by rani....@gmail.com on 12 Jun 2009 at 6:09

GoogleCodeExporter commented 9 years ago
You can most definitively test a method that calls super, but unfortunately you
cannot mock/suppress/stub the call to super right now. What you can do however 
is of
course to mock/stub everything in the super method. If you like the behavior to 
be
reused you can implement it using a mock policy. I've made an example of this, 
the
test is here: 
http://code.google.com/p/powermock/source/browse/trunk/modules/module-test/power
mock/junit4-test/src/test/java/samples/junit4/mockpolicy/MockPolicyUsageExampleT
est.java
which tests:
http://code.google.com/p/powermock/source/browse/trunk/tests/utils/src/main/java
/samples/mockpolicy/SomeClassWithAMethod.java

In the future please use our mailing-list for these kinds of questions (join our
google group and then send an e-mail to powermock@googlegroups.com).

Good luck.

Original comment by johan.ha...@gmail.com on 12 Jun 2009 at 6:47

GoogleCodeExporter commented 9 years ago
Perhaps we could make use of invokeSuper in MethodProxy in CgLib

Original comment by johan.ha...@gmail.com on 2 Sep 2009 at 4:55

GoogleCodeExporter commented 9 years ago
Will be moved to a future relase

Original comment by johan.ha...@gmail.com on 11 Sep 2009 at 6:24

GoogleCodeExporter commented 9 years ago
Has this issue been addressed? 

I am having a issue related to this where I am trying to mock a method call to 
a parent class. Any information would be appreciated.

http://stackoverflow.com/questions/8882806/powermokito-issue-with-extended-metho
ds

Original comment by Mark.FDM...@gmail.com on 16 Jan 2012 at 7:08

GoogleCodeExporter commented 9 years ago
I don't think it's possible to do this in Java because of the way polymorphism 
works.

Original comment by johan.ha...@gmail.com on 16 Jan 2012 at 7:37

GoogleCodeExporter commented 9 years ago
Thanks for your response Johan. Sort of puts me in a tight spot in the 
situation I am in. SuppressAll doesn't work, would using a replace with 
invocation work?

Original comment by Mark.FDM...@gmail.com on 16 Jan 2012 at 7:41

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
I've made a fix for this issue regarding the suppressing of the super call of 
the overridden method.

Original comment by hpb...@gmail.com on 25 Jul 2012 at 9:37

Attachments:

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

Original comment by johan.ha...@gmail.com on 25 Jul 2012 at 11:23

GoogleCodeExporter commented 9 years ago
I've applied the patch to trunk. Please verify!

Original comment by johan.ha...@gmail.com on 25 Jul 2012 at 11:25

GoogleCodeExporter commented 9 years ago
The patch also introduces a new class: ClassLocator
Please add this class too (maybe change the package location).

Original comment by hpb...@gmail.com on 25 Jul 2012 at 12:53

GoogleCodeExporter commented 9 years ago
Sorry I forgot it. I've added it now.

Original comment by johan.ha...@gmail.com on 25 Jul 2012 at 1:13

GoogleCodeExporter commented 9 years ago
I've verified it. Thanks for integrating the patch.

Original comment by hpb...@gmail.com on 25 Jul 2012 at 1:32

GoogleCodeExporter commented 9 years ago
Thanks for your help! Would be good if someone else could verify it as well.

Original comment by johan.ha...@gmail.com on 25 Jul 2012 at 1:41

GoogleCodeExporter commented 9 years ago
Hi all - Trying to verify this as well. Has this been pushed to public maven 
repos just yet btw?

Original comment by kkuh...@gmail.com on 2 Aug 2012 at 7:18

GoogleCodeExporter commented 9 years ago
No it's only available in the trunk. You have to build powermock from the 
sources. Just do mvn clean install -Dmaven.javadoc.skip=true and you should be 
fine.

Original comment by johan.ha...@gmail.com on 2 Aug 2012 at 7:31

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

Original comment by johan.ha...@gmail.com on 4 Aug 2012 at 5:53

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

Original comment by johan.ha...@gmail.com on 4 Aug 2012 at 5:53

GoogleCodeExporter commented 9 years ago
Is this patch available yet?

Original comment by corykend...@gmail.com on 15 Nov 2012 at 4:03

GoogleCodeExporter commented 9 years ago
No it's only available in the trunk. You have to build powermock from the 
sources. Just do mvn clean install -Dmaven.javadoc.skip=true and you should be 
fine.

Original comment by johan.ha...@gmail.com on 15 Nov 2012 at 8:16