<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Untestable code with Mockito and PowerMock</title>
	<atom:link href="http://blog.jayway.com/2009/10/28/untestable-code-with-mockito-and-powermock/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.jayway.com/2009/10/28/untestable-code-with-mockito-and-powermock/</link>
	<description>Sharing Experience</description>
	<lastBuildDate>Sun, 12 Feb 2012 05:23:29 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Adeel Khokhar</title>
		<link>http://blog.jayway.com/2009/10/28/untestable-code-with-mockito-and-powermock/comment-page-1/#comment-78509</link>
		<dc:creator>Adeel Khokhar</dc:creator>
		<pubDate>Tue, 26 Jul 2011 10:52:43 +0000</pubDate>
		<guid isPermaLink="false">http://blog.jayway.com/?p=2180#comment-78509</guid>
		<description>Hello sir...

All the examples are so useful ,I was in process to learn about PowerMocking and after going through these examples I have got a good idea about.Well done.


I hope you&#039;ll keep updating us with new examples in future.</description>
		<content:encoded><![CDATA[<p>Hello sir&#8230;</p>
<p>All the examples are so useful ,I was in process to learn about PowerMocking and after going through these examples I have got a good idea about.Well done.</p>
<p>I hope you&#8217;ll keep updating us with new examples in future.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ra</title>
		<link>http://blog.jayway.com/2009/10/28/untestable-code-with-mockito-and-powermock/comment-page-1/#comment-78491</link>
		<dc:creator>ra</dc:creator>
		<pubDate>Sat, 16 Jul 2011 20:16:49 +0000</pubDate>
		<guid isPermaLink="false">http://blog.jayway.com/?p=2180#comment-78491</guid>
		<description>I have a test case where I would like to mock out multiple thrid party final classes in the same test case.  Is there any way this can be done?

The @PrepareForTest annotation can only be included once with one entry.

Thanks</description>
		<content:encoded><![CDATA[<p>I have a test case where I would like to mock out multiple thrid party final classes in the same test case.  Is there any way this can be done?</p>
<p>The @PrepareForTest annotation can only be included once with one entry.</p>
<p>Thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: enric</title>
		<link>http://blog.jayway.com/2009/10/28/untestable-code-with-mockito-and-powermock/comment-page-1/#comment-62799</link>
		<dc:creator>enric</dc:creator>
		<pubDate>Thu, 28 Oct 2010 15:02:12 +0000</pubDate>
		<guid isPermaLink="false">http://blog.jayway.com/?p=2180#comment-62799</guid>
		<description>replace()  worked for me by creating the mock with PowerMockito.spy(class). I think this isn&#039;t said in this post</description>
		<content:encoded><![CDATA[<p>replace()  worked for me by creating the mock with PowerMockito.spy(class). I think this isn&#8217;t said in this post</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: AllanC</title>
		<link>http://blog.jayway.com/2009/10/28/untestable-code-with-mockito-and-powermock/comment-page-1/#comment-56519</link>
		<dc:creator>AllanC</dc:creator>
		<pubDate>Mon, 13 Sep 2010 18:20:57 +0000</pubDate>
		<guid isPermaLink="false">http://blog.jayway.com/?p=2180#comment-56519</guid>
		<description>Very nice. I am moving our team onto our first mocking tool and it will be Mockito + Powermock. Nice job.</description>
		<content:encoded><![CDATA[<p>Very nice. I am moving our team onto our first mocking tool and it will be Mockito + Powermock. Nice job.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Balrajcse</title>
		<link>http://blog.jayway.com/2009/10/28/untestable-code-with-mockito-and-powermock/comment-page-1/#comment-49488</link>
		<dc:creator>Balrajcse</dc:creator>
		<pubDate>Mon, 26 Jul 2010 20:38:23 +0000</pubDate>
		<guid isPermaLink="false">http://blog.jayway.com/?p=2180#comment-49488</guid>
		<description>I have method call like 

public void processRetrievedData() {
super.processRetrievedData();
}

is there anyway to mock &quot;super.processRetrievedData()&quot; this.</description>
		<content:encoded><![CDATA[<p>I have method call like </p>
<p>public void processRetrievedData() {<br />
super.processRetrievedData();<br />
}</p>
<p>is there anyway to mock &#8220;super.processRetrievedData()&#8221; this.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Deep Shah</title>
		<link>http://blog.jayway.com/2009/10/28/untestable-code-with-mockito-and-powermock/comment-page-1/#comment-38373</link>
		<dc:creator>Deep Shah</dc:creator>
		<pubDate>Tue, 11 May 2010 05:27:12 +0000</pubDate>
		<guid isPermaLink="false">http://blog.jayway.com/?p=2180#comment-38373</guid>
		<description>Excellent Post!  
Taking inspiration from you, I have also written a post on how to test the untestable code (with an example taken from JMockit samples).  I am showing various ways in which we can write good unit-tests for the code under test using the PowerMocks (Mockito api).

Here is the link:
http://www.gitshah.com/2010/05/testing-untestable-code-using.html</description>
		<content:encoded><![CDATA[<p>Excellent Post!<br />
Taking inspiration from you, I have also written a post on how to test the untestable code (with an example taken from JMockit samples).  I am showing various ways in which we can write good unit-tests for the code under test using the PowerMocks (Mockito api).</p>
<p>Here is the link:<br />
<a href="http://www.gitshah.com/2010/05/testing-untestable-code-using.html" rel="nofollow">http://www.gitshah.com/2010/05/testing-untestable-code-using.html</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ankush Goyal</title>
		<link>http://blog.jayway.com/2009/10/28/untestable-code-with-mockito-and-powermock/comment-page-1/#comment-30834</link>
		<dc:creator>Ankush Goyal</dc:creator>
		<pubDate>Wed, 17 Mar 2010 15:17:36 +0000</pubDate>
		<guid isPermaLink="false">http://blog.jayway.com/?p=2180#comment-30834</guid>
		<description>Hi Johan,

I am using ant/ savant for dependencies and this is what I have in my project&#039;s build-deps file :


      
      
      

Basically I am using the powermock-mockito-junit-1.3.6.zip and I don&#039;t have any other version of mockito.</description>
		<content:encoded><![CDATA[<p>Hi Johan,</p>
<p>I am using ant/ savant for dependencies and this is what I have in my project&#8217;s build-deps file :</p>
<p>Basically I am using the powermock-mockito-junit-1.3.6.zip and I don&#8217;t have any other version of mockito.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Johan Haleby</title>
		<link>http://blog.jayway.com/2009/10/28/untestable-code-with-mockito-and-powermock/comment-page-1/#comment-30810</link>
		<dc:creator>Johan Haleby</dc:creator>
		<pubDate>Wed, 17 Mar 2010 08:43:35 +0000</pubDate>
		<guid isPermaLink="false">http://blog.jayway.com/?p=2180#comment-30810</guid>
		<description>Hi,

This is probably because you&#039;re using a version of PowerMock that is not compatible with Mocktio 1.8.3. See the documentation at (http://code.google.com/p/powermock/wiki/MockitoUsage13) for which version to use.

/Johan</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>This is probably because you&#8217;re using a version of PowerMock that is not compatible with Mocktio 1.8.3. See the documentation at (<a href="http://code.google.com/p/powermock/wiki/MockitoUsage13" rel="nofollow">http://code.google.com/p/powermock/wiki/MockitoUsage13</a>) for which version to use.</p>
<p>/Johan</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ankush Goyal</title>
		<link>http://blog.jayway.com/2009/10/28/untestable-code-with-mockito-and-powermock/comment-page-1/#comment-30791</link>
		<dc:creator>Ankush Goyal</dc:creator>
		<pubDate>Tue, 16 Mar 2010 23:20:23 +0000</pubDate>
		<guid isPermaLink="false">http://blog.jayway.com/?p=2180#comment-30791</guid>
		<description>I am using PowerMockito(1.3.6) with Mockito(1.8.3) and Junit(4.7) for testing. I am quite stuck on an error:

[junit] Testcase: testNextPNRFromQueueHappyPath(com.orbitz.galileo.host.robot.GalpoQueueConnectionTest):    Caused an ERROR
[junit] org/mockito/internal/IMockHandler
[junit] java.lang.NoClassDefFoundError: org/mockito/internal/IMockHandler
[junit]     at org.powermock.api.mockito.internal.expectation.DefaultConstructorExpectationSetup.createNewSubsituteMock(DefaultConstructorExpectationSetup.java:80)
[junit]     at org.powermock.api.mockito.internal.expectation.DefaultConstructorExpectationSetup.withArguments(DefaultConstructorExpectationSetup.java:48)
[junit]     at com.orbitz.galileo.host.robot.GalpoQueueConnectionTest.testNextPNRFromQueueHappyPath(GalpoQueueConnectionTest.java:62)
[junit]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[junit]     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
[junit]     at     sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

My class under test : GalpoQueueConnection is basically creating a new object of another class : QueueReadBuilder. I am trying to do something like:

@RunWith(PowerMockRunner.class)
@PrepareForTest({GalpoQueueConnection.class, ApolloProcUtils.class})
public class GalpoQueueConnectionTest extends TestCase{
@Test
public void testNextPNRFromQueueHappyPath() throws Exception {
    QueueReadBuilder mockBuilder = mock(QueueReadBuilder.class);
    PowerMockito.whenNew(QueueReadBuilder.class).withArguments(anyString(),   anyString(), anyString()).thenReturn(mockBuilder);
    }
}

It seems like somehow powermockito is trying to call IMockHandler, and I looked at Mockito 1.8.3 api, and there isn&#039;t any.

Any suggestions/ clues would be welcome.</description>
		<content:encoded><![CDATA[<p>I am using PowerMockito(1.3.6) with Mockito(1.8.3) and Junit(4.7) for testing. I am quite stuck on an error:</p>
<p>[junit] Testcase: testNextPNRFromQueueHappyPath(com.orbitz.galileo.host.robot.GalpoQueueConnectionTest):    Caused an ERROR<br />
[junit] org/mockito/internal/IMockHandler<br />
[junit] java.lang.NoClassDefFoundError: org/mockito/internal/IMockHandler<br />
[junit]     at org.powermock.api.mockito.internal.expectation.DefaultConstructorExpectationSetup.createNewSubsituteMock(DefaultConstructorExpectationSetup.java:80)<br />
[junit]     at org.powermock.api.mockito.internal.expectation.DefaultConstructorExpectationSetup.withArguments(DefaultConstructorExpectationSetup.java:48)<br />
[junit]     at com.orbitz.galileo.host.robot.GalpoQueueConnectionTest.testNextPNRFromQueueHappyPath(GalpoQueueConnectionTest.java:62)<br />
[junit]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)<br />
[junit]     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)<br />
[junit]     at     sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)</p>
<p>My class under test : GalpoQueueConnection is basically creating a new object of another class : QueueReadBuilder. I am trying to do something like:</p>
<p>@RunWith(PowerMockRunner.class)<br />
@PrepareForTest({GalpoQueueConnection.class, ApolloProcUtils.class})<br />
public class GalpoQueueConnectionTest extends TestCase{<br />
@Test<br />
public void testNextPNRFromQueueHappyPath() throws Exception {<br />
    QueueReadBuilder mockBuilder = mock(QueueReadBuilder.class);<br />
    PowerMockito.whenNew(QueueReadBuilder.class).withArguments(anyString(),   anyString(), anyString()).thenReturn(mockBuilder);<br />
    }<br />
}</p>
<p>It seems like somehow powermockito is trying to call IMockHandler, and I looked at Mockito 1.8.3 api, and there isn&#8217;t any.</p>
<p>Any suggestions/ clues would be welcome.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: srikanth</title>
		<link>http://blog.jayway.com/2009/10/28/untestable-code-with-mockito-and-powermock/comment-page-1/#comment-20299</link>
		<dc:creator>srikanth</dc:creator>
		<pubDate>Wed, 30 Dec 2009 18:36:36 +0000</pubDate>
		<guid isPermaLink="false">http://blog.jayway.com/?p=2180#comment-20299</guid>
		<description>The following doesn&#039;t seem to work
PowerMockito.mockStatic(Integer.class);
when(Integer.parseInt(anyString())).thenReturn(1);
System.out.println(Integer.parseInt(&quot;12&quot;));

i am getting &#039;unfinished stubbing detected&#039; exception. 
 changed the string part to this

when(Integer.parseInt(eq(&quot;12&quot;))).thenReturn(1);

but getting the same exception

But the following works
when(Integer.toString(anyInt())).thenReturn(&quot;hello&quot;);
Integer.toString(12);
Is this a bug or Am i missing something?</description>
		<content:encoded><![CDATA[<p>The following doesn&#8217;t seem to work<br />
PowerMockito.mockStatic(Integer.class);<br />
when(Integer.parseInt(anyString())).thenReturn(1);<br />
System.out.println(Integer.parseInt(&#8220;12&#8243;));</p>
<p>i am getting &#8216;unfinished stubbing detected&#8217; exception.<br />
 changed the string part to this</p>
<p>when(Integer.parseInt(eq(&#8220;12&#8243;))).thenReturn(1);</p>
<p>but getting the same exception</p>
<p>But the following works<br />
when(Integer.toString(anyInt())).thenReturn(&#8220;hello&#8221;);<br />
Integer.toString(12);<br />
Is this a bug or Am i missing something?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Johan Haleby</title>
		<link>http://blog.jayway.com/2009/10/28/untestable-code-with-mockito-and-powermock/comment-page-1/#comment-18789</link>
		<dc:creator>Johan Haleby</dc:creator>
		<pubDate>Tue, 15 Dec 2009 12:57:48 +0000</pubDate>
		<guid isPermaLink="false">http://blog.jayway.com/?p=2180#comment-18789</guid>
		<description>PowerMock 1.3.5 is now released and it has support for TestNG 5.11</description>
		<content:encoded><![CDATA[<p>PowerMock 1.3.5 is now released and it has support for TestNG 5.11</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Johan Haleby</title>
		<link>http://blog.jayway.com/2009/10/28/untestable-code-with-mockito-and-powermock/comment-page-1/#comment-16479</link>
		<dc:creator>Johan Haleby</dc:creator>
		<pubDate>Wed, 25 Nov 2009 08:12:37 +0000</pubDate>
		<guid isPermaLink="false">http://blog.jayway.com/?p=2180#comment-16479</guid>
		<description>It&#039;s currently not possible to mock super calls. You could try to suppress the method in your super class but I&#039;m not 100% sure if that works either.

/Johan</description>
		<content:encoded><![CDATA[<p>It&#8217;s currently not possible to mock super calls. You could try to suppress the method in your super class but I&#8217;m not 100% sure if that works either.</p>
<p>/Johan</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Setya</title>
		<link>http://blog.jayway.com/2009/10/28/untestable-code-with-mockito-and-powermock/comment-page-1/#comment-16471</link>
		<dc:creator>Setya</dc:creator>
		<pubDate>Wed, 25 Nov 2009 07:53:23 +0000</pubDate>
		<guid isPermaLink="false">http://blog.jayway.com/?p=2180#comment-16471</guid>
		<description>Hi,

I have inherited method that calls &#039;super()&#039; followed by my own implementation. I want to test this method by calling my own implementation without &#039;super()&#039; call. Is it possible to do this with Mockito &amp; PowerMock ?

Regards,

Setya</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>I have inherited method that calls &#8216;super()&#8217; followed by my own implementation. I want to test this method by calling my own implementation without &#8216;super()&#8217; call. Is it possible to do this with Mockito &amp; PowerMock ?</p>
<p>Regards,</p>
<p>Setya</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Johan Haleby</title>
		<link>http://blog.jayway.com/2009/10/28/untestable-code-with-mockito-and-powermock/comment-page-1/#comment-15557</link>
		<dc:creator>Johan Haleby</dc:creator>
		<pubDate>Thu, 12 Nov 2009 07:52:19 +0000</pubDate>
		<guid isPermaLink="false">http://blog.jayway.com/?p=2180#comment-15557</guid>
		<description>Yes it should, I&#039;ve corrected it now. Thanks for spotting it.</description>
		<content:encoded><![CDATA[<p>Yes it should, I&#8217;ve corrected it now. Thanks for spotting it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Johan Martinsson</title>
		<link>http://blog.jayway.com/2009/10/28/untestable-code-with-mockito-and-powermock/comment-page-1/#comment-15495</link>
		<dc:creator>Johan Martinsson</dc:creator>
		<pubDate>Wed, 11 Nov 2009 18:30:30 +0000</pubDate>
		<guid isPermaLink="false">http://blog.jayway.com/?p=2180#comment-15495</guid>
		<description>Great functionality! 

But trying out the first example I couldn&#039;t get it to work. Shouldn&#039;t it be
mockStatic(IdGenerator.class ) instead of 
mock(IdGenerator.class) ?</description>
		<content:encoded><![CDATA[<p>Great functionality! </p>
<p>But trying out the first example I couldn&#8217;t get it to work. Shouldn&#8217;t it be<br />
mockStatic(IdGenerator.class ) instead of<br />
mock(IdGenerator.class) ?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Christophe Furmaniak</title>
		<link>http://blog.jayway.com/2009/10/28/untestable-code-with-mockito-and-powermock/comment-page-1/#comment-15312</link>
		<dc:creator>Christophe Furmaniak</dc:creator>
		<pubDate>Sat, 07 Nov 2009 20:43:59 +0000</pubDate>
		<guid isPermaLink="false">http://blog.jayway.com/?p=2180#comment-15312</guid>
		<description>I&#039;ve started to use PowerMock with some JUnit tests and that&#039;s really amazing to be able to mock final classes (for instance, some singletons with no public constructor) that comes from some old lib you have to use because they are provided by your company and you don&#039;t have the choice.

So, again, Thanks a lot! (and thanks for the upcoming TestNG support :D)</description>
		<content:encoded><![CDATA[<p>I&#8217;ve started to use PowerMock with some JUnit tests and that&#8217;s really amazing to be able to mock final classes (for instance, some singletons with no public constructor) that comes from some old lib you have to use because they are provided by your company and you don&#8217;t have the choice.</p>
<p>So, again, Thanks a lot! (and thanks for the upcoming TestNG support <img src='http://blog.jayway.com/wordpress/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> )</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Johan Haleby</title>
		<link>http://blog.jayway.com/2009/10/28/untestable-code-with-mockito-and-powermock/comment-page-1/#comment-15154</link>
		<dc:creator>Johan Haleby</dc:creator>
		<pubDate>Wed, 04 Nov 2009 21:37:18 +0000</pubDate>
		<guid isPermaLink="false">http://blog.jayway.com/?p=2180#comment-15154</guid>
		<description>Thanks!

We&#039;ve been working together with a member of the TestNG team in order to get it working but unfortunately there&#039;s a bug in the latest version of TestNG which prevents this from happening. The next version of TestNG will hopefully work with PowerMock (at least basic support, which will be good enough for regular use).</description>
		<content:encoded><![CDATA[<p>Thanks!</p>
<p>We&#8217;ve been working together with a member of the TestNG team in order to get it working but unfortunately there&#8217;s a bug in the latest version of TestNG which prevents this from happening. The next version of TestNG will hopefully work with PowerMock (at least basic support, which will be good enough for regular use).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Christophe Furmaniak</title>
		<link>http://blog.jayway.com/2009/10/28/untestable-code-with-mockito-and-powermock/comment-page-1/#comment-15118</link>
		<dc:creator>Christophe Furmaniak</dc:creator>
		<pubDate>Wed, 04 Nov 2009 10:33:50 +0000</pubDate>
		<guid isPermaLink="false">http://blog.jayway.com/?p=2180#comment-15118</guid>
		<description>oops! did not notice before that only JUnit was supported. Any TestNG support on its way?</description>
		<content:encoded><![CDATA[<p>oops! did not notice before that only JUnit was supported. Any TestNG support on its way?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Christophe Furmaniak</title>
		<link>http://blog.jayway.com/2009/10/28/untestable-code-with-mockito-and-powermock/comment-page-1/#comment-15117</link>
		<dc:creator>Christophe Furmaniak</dc:creator>
		<pubDate>Wed, 04 Nov 2009 10:32:03 +0000</pubDate>
		<guid isPermaLink="false">http://blog.jayway.com/?p=2180#comment-15117</guid>
		<description>Seems really cool! I&#039;m gonna give it a try right now :).</description>
		<content:encoded><![CDATA[<p>Seems really cool! I&#8217;m gonna give it a try right now <img src='http://blog.jayway.com/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
]]></content:encoded>
	</item>
</channel>
</rss>

