<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: expected exception in tests</title>
	<atom:link href="http://monkeyisland.pl/2010/07/26/expected-exception-in-tests/feed/" rel="self" type="application/rss+xml" />
	<link>http://monkeyisland.pl/2010/07/26/expected-exception-in-tests/</link>
	<description>about software</description>
	<lastBuildDate>Fri, 11 May 2012 11:03:02 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: rod</title>
		<link>http://monkeyisland.pl/2010/07/26/expected-exception-in-tests/#comment-3938</link>
		<dc:creator><![CDATA[rod]]></dc:creator>
		<pubDate>Fri, 10 Feb 2012 15:14:10 +0000</pubDate>
		<guid isPermaLink="false">http://monkeyisland.pl/?p=401#comment-3938</guid>
		<description><![CDATA[Hi Szczepan, I liked your ideas and I made them part of the latest version of catch-exception. Thank you for your suggestions :-)

Rod]]></description>
		<content:encoded><![CDATA[<p>Hi Szczepan, I liked your ideas and I made them part of the latest version of catch-exception. Thank you for your suggestions :-)</p>
<p>Rod</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anonymous</title>
		<link>http://monkeyisland.pl/2010/07/26/expected-exception-in-tests/#comment-3931</link>
		<dc:creator><![CDATA[Anonymous]]></dc:creator>
		<pubDate>Sat, 07 Jan 2012 22:51:25 +0000</pubDate>
		<guid isPermaLink="false">http://monkeyisland.pl/?p=401#comment-3931</guid>
		<description><![CDATA[This style is steller! You definitely know how to maintain a reader entertained. Between your wit and your videos, I was almost moved to start my own blog (well, almostâ€¦HaHa!) Amazing job. I genuinely enjoyed what you had to say, and far more than that, how you presented it. Too cool!]]></description>
		<content:encoded><![CDATA[<p>This style is steller! You definitely know how to maintain a reader entertained. Between your wit and your videos, I was almost moved to start my own blog (well, almostâ€¦HaHa!) Amazing job. I genuinely enjoyed what you had to say, and far more than that, how you presented it. Too cool!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: szczepiq</title>
		<link>http://monkeyisland.pl/2010/07/26/expected-exception-in-tests/#comment-3859</link>
		<dc:creator><![CDATA[szczepiq]]></dc:creator>
		<pubDate>Sun, 30 Oct 2011 08:47:59 +0000</pubDate>
		<guid isPermaLink="false">http://monkeyisland.pl/?p=401#comment-3859</guid>
		<description><![CDATA[I like your library :) It&#039;s a bit too late for me to use it since I&#039;m mostly with groovy these days doing a lot of spock testing.

The api looks good, the name of the library is good. Still, there&#039;re always of ways you can play with the API so you should have a lot fun with it :), for example:

when(foo).bar();
thenThrown(RuntimeException.class);

or:

//given
...
//then
thrown(RuntimeException.class).when(foo).bar();

//sort of consistent with Mockito api:
verifyThrown(RuntimeException.class).when(foo).bar();
verifyThrown(messageContains(&quot;foo&quot;)).when(foo).bar();

Also regarding the API, you might want to lean towards consistency with other frameworks, e.g. fest assert - build the api starting with assertThat, or mockito - make sure the method names don&#039;t clash and do not overlap, etc. This way your framework will be nicely pluggable to existing testing toolkits many devs use.

Hope that helps and good luck!]]></description>
		<content:encoded><![CDATA[<p>I like your library :) It&#8217;s a bit too late for me to use it since I&#8217;m mostly with groovy these days doing a lot of spock testing.</p>
<p>The api looks good, the name of the library is good. Still, there&#8217;re always of ways you can play with the API so you should have a lot fun with it :), for example:</p>
<p>when(foo).bar();<br />
thenThrown(RuntimeException.class);</p>
<p>or:</p>
<p>//given<br />
&#8230;<br />
//then<br />
thrown(RuntimeException.class).when(foo).bar();</p>
<p>//sort of consistent with Mockito api:<br />
verifyThrown(RuntimeException.class).when(foo).bar();<br />
verifyThrown(messageContains(&#8220;foo&#8221;)).when(foo).bar();</p>
<p>Also regarding the API, you might want to lean towards consistency with other frameworks, e.g. fest assert &#8211; build the api starting with assertThat, or mockito &#8211; make sure the method names don&#8217;t clash and do not overlap, etc. This way your framework will be nicely pluggable to existing testing toolkits many devs use.</p>
<p>Hope that helps and good luck!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rod Woo</title>
		<link>http://monkeyisland.pl/2010/07/26/expected-exception-in-tests/#comment-3850</link>
		<dc:creator><![CDATA[Rod Woo]]></dc:creator>
		<pubDate>Fri, 28 Oct 2011 10:04:03 +0000</pubDate>
		<guid isPermaLink="false">http://monkeyisland.pl/?p=401#comment-3850</guid>
		<description><![CDATA[Hi Szczepan,

as you I felt quite uncomfortable with JUnit&#039;s approach of testing expected exceptions. So I used Mockito to implement a little helper that addresses the issues: http://code.google.com/p/catch-exception/

I would like to here your opinion about that.

Rod]]></description>
		<content:encoded><![CDATA[<p>Hi Szczepan,</p>
<p>as you I felt quite uncomfortable with JUnit&#8217;s approach of testing expected exceptions. So I used Mockito to implement a little helper that addresses the issues: <a href="http://code.google.com/p/catch-exception/" rel="nofollow">http://code.google.com/p/catch-exception/</a></p>
<p>I would like to here your opinion about that.</p>
<p>Rod</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Roger Norling</title>
		<link>http://monkeyisland.pl/2010/07/26/expected-exception-in-tests/#comment-3748</link>
		<dc:creator><![CDATA[Roger Norling]]></dc:creator>
		<pubDate>Mon, 10 Jan 2011 18:07:14 +0000</pubDate>
		<guid isPermaLink="false">http://monkeyisland.pl/?p=401#comment-3748</guid>
		<description><![CDATA[Hi Szczepan

I found your blog through the Mockito homepage.

Have you seen Antony Marcano&#039;s way of verifying thrown exceptions (http://antonymarcano.com/blog/2010/07/old-favourite-expected-exceptions/)? I find it realy good because it follows the given/when/then pattern so nicely.

In essence, this is his pattern (slightly edited by me):
&lt;code&gt;@Test
public void shouldVerifyAThrownExampleException() throws Exception {
    // given
    // ...
    Exception thrown = null;

    try {
        // when
        // ...
    } catch (Exception caught) {
        thrown = caught;
    }

    // then
    assertThat(thrown, is(instanceOf(ExampleException.class)));
}
&lt;/code&gt;

Perhaps a bit more lengthy, but that&#039;s easily fixed by a code template.]]></description>
		<content:encoded><![CDATA[<p>Hi Szczepan</p>
<p>I found your blog through the Mockito homepage.</p>
<p>Have you seen Antony Marcano&#8217;s way of verifying thrown exceptions (<a href="http://antonymarcano.com/blog/2010/07/old-favourite-expected-exceptions/" rel="nofollow">http://antonymarcano.com/blog/2010/07/old-favourite-expected-exceptions/</a>)? I find it realy good because it follows the given/when/then pattern so nicely.</p>
<p>In essence, this is his pattern (slightly edited by me):<br />
<code>@Test<br />
public void shouldVerifyAThrownExampleException() throws Exception {<br />
    // given<br />
    // ...<br />
    Exception thrown = null;</p>
<p>    try {<br />
        // when<br />
        // ...<br />
    } catch (Exception caught) {<br />
        thrown = caught;<br />
    }</p>
<p>    // then<br />
    assertThat(thrown, is(instanceOf(ExampleException.class)));<br />
}<br />
</code></p>
<p>Perhaps a bit more lengthy, but that&#8217;s easily fixed by a code template.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Erik</title>
		<link>http://monkeyisland.pl/2010/07/26/expected-exception-in-tests/#comment-3734</link>
		<dc:creator><![CDATA[Erik]]></dc:creator>
		<pubDate>Tue, 28 Dec 2010 17:58:46 +0000</pubDate>
		<guid isPermaLink="false">http://monkeyisland.pl/?p=401#comment-3734</guid>
		<description><![CDATA[Ok, so I have to comment on this.  Your proposed &quot;solution&quot; doesn&#039;t alleviate the problem at all.  You&#039;re still dependent on the original developer &lt;i&gt;knowing how to write a good test&lt;/i&gt;.  You properly catch BreadOutOfStockException in Rule 3, but had the developer caught Exception instead you&#039;d be right back to square one.  In short, Rule 3 is just Rule 2 but with more bloat.]]></description>
		<content:encoded><![CDATA[<p>Ok, so I have to comment on this.  Your proposed &#8220;solution&#8221; doesn&#8217;t alleviate the problem at all.  You&#8217;re still dependent on the original developer <i>knowing how to write a good test</i>.  You properly catch BreadOutOfStockException in Rule 3, but had the developer caught Exception instead you&#8217;d be right back to square one.  In short, Rule 3 is just Rule 2 but with more bloat.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: szczepiq</title>
		<link>http://monkeyisland.pl/2010/07/26/expected-exception-in-tests/#comment-3635</link>
		<dc:creator><![CDATA[szczepiq]]></dc:creator>
		<pubDate>Tue, 05 Oct 2010 08:03:21 +0000</pubDate>
		<guid isPermaLink="false">http://monkeyisland.pl/?p=401#comment-3635</guid>
		<description><![CDATA[There are number of ways of testing exceptions and this post tries to rank them. I don&#039;t see a contradiction but if you see it... I guess I will have to live with this somehow =)

I&#039;m dogmatic, every coach is. I don&#039;t like features that on average day lead to poor code. I&#039;m sure you are RI enough to see the big picture 8-)]]></description>
		<content:encoded><![CDATA[<p>There are number of ways of testing exceptions and this post tries to rank them. I don&#8217;t see a contradiction but if you see it&#8230; I guess I will have to live with this somehow =)</p>
<p>I&#8217;m dogmatic, every coach is. I don&#8217;t like features that on average day lead to poor code. I&#8217;m sure you are RI enough to see the big picture 8-)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tomek</title>
		<link>http://monkeyisland.pl/2010/07/26/expected-exception-in-tests/#comment-3634</link>
		<dc:creator><![CDATA[Tomek]]></dc:creator>
		<pubDate>Tue, 05 Oct 2010 07:40:06 +0000</pubDate>
		<guid isPermaLink="false">http://monkeyisland.pl/?p=401#comment-3634</guid>
		<description><![CDATA[Szczepan, read the beginning of your post again - you say there that &quot;(expected = SomeException.class) // IS BAD FOR YOU&quot; (notice the CAPITAL LETTERS) and that you &quot;don’t like @Test(expected) feature of jUnit.&quot;

This is in contradiction to what you say now:
&quot;I don&#039;t say you should not test exception&quot;.

So is it bad or not? Is it bad or is it a useful feature which can be misused? Should you test your exception or you shouldn&#039;t because this &quot;is bad for you&quot;?

Sounds schizophrenic to me. ;)

--
Cheers,
Tomek Kaczanowski]]></description>
		<content:encoded><![CDATA[<p>Szczepan, read the beginning of your post again &#8211; you say there that &#8220;(expected = SomeException.class) // IS BAD FOR YOU&#8221; (notice the CAPITAL LETTERS) and that you &#8220;don’t like @Test(expected) feature of jUnit.&#8221;</p>
<p>This is in contradiction to what you say now:<br />
&#8220;I don&#8217;t say you should not test exception&#8221;.</p>
<p>So is it bad or not? Is it bad or is it a useful feature which can be misused? Should you test your exception or you shouldn&#8217;t because this &#8220;is bad for you&#8221;?</p>
<p>Sounds schizophrenic to me. ;)</p>
<p>&#8211;<br />
Cheers,<br />
Tomek Kaczanowski</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: szczepiq</title>
		<link>http://monkeyisland.pl/2010/07/26/expected-exception-in-tests/#comment-3633</link>
		<dc:creator><![CDATA[szczepiq]]></dc:creator>
		<pubDate>Tue, 05 Oct 2010 06:54:15 +0000</pubDate>
		<guid isPermaLink="false">http://monkeyisland.pl/?p=401#comment-3633</guid>
		<description><![CDATA[I wrote this article after someone (again) posted a code snippet to the mockito mailing list with glaring misuse of @Test(expected). I found myself teaching the same thing over and over again so I blogged about it. Trust me, I&#039;m lazy. I wouldn&#039;t write anything if there wasn&#039;t an incentive for me - now I can simply pass on the link!

I&#039;m not sure what you disagree with... I don&#039;t say you should not test exceptions. I try to give generic guidelines on how to test exceptions *successfully* =)

Why don&#039;t I use TestNG? I find jUnit slightly better integrated with tools I use and there&#039;s very little extra in TestNG api that I need. Both tools are ok =)]]></description>
		<content:encoded><![CDATA[<p>I wrote this article after someone (again) posted a code snippet to the mockito mailing list with glaring misuse of @Test(expected). I found myself teaching the same thing over and over again so I blogged about it. Trust me, I&#8217;m lazy. I wouldn&#8217;t write anything if there wasn&#8217;t an incentive for me &#8211; now I can simply pass on the link!</p>
<p>I&#8217;m not sure what you disagree with&#8230; I don&#8217;t say you should not test exceptions. I try to give generic guidelines on how to test exceptions *successfully* =)</p>
<p>Why don&#8217;t I use TestNG? I find jUnit slightly better integrated with tools I use and there&#8217;s very little extra in TestNG api that I need. Both tools are ok =)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tomek</title>
		<link>http://monkeyisland.pl/2010/07/26/expected-exception-in-tests/#comment-3632</link>
		<dc:creator><![CDATA[Tomek]]></dc:creator>
		<pubDate>Mon, 04 Oct 2010 20:11:49 +0000</pubDate>
		<guid isPermaLink="false">http://monkeyisland.pl/?p=401#comment-3632</guid>
		<description><![CDATA[Hello Szczepan,

I never had any problems with misuse of expected exceptions (and I have done enough of code reviews) so I&#039;m little surprised that you consider it to be a serious problem worth blogging about.

Anyway, I think I don&#039;t agree. :) If my method throws sensible exceptions then they are a part of its API (yes, they are) and should be tested. Thus expected exceptions is one of many tools in my testing toolbox.

BTW. Why do you use jUnit and not TestNG? Yeah, I know - curiosity killed the cat - but it still surprises me that people stick to old, good jUnit.

--
Cheers,
Tomek Kaczanowski]]></description>
		<content:encoded><![CDATA[<p>Hello Szczepan,</p>
<p>I never had any problems with misuse of expected exceptions (and I have done enough of code reviews) so I&#8217;m little surprised that you consider it to be a serious problem worth blogging about.</p>
<p>Anyway, I think I don&#8217;t agree. :) If my method throws sensible exceptions then they are a part of its API (yes, they are) and should be tested. Thus expected exceptions is one of many tools in my testing toolbox.</p>
<p>BTW. Why do you use jUnit and not TestNG? Yeah, I know &#8211; curiosity killed the cat &#8211; but it still surprises me that people stick to old, good jUnit.</p>
<p>&#8211;<br />
Cheers,<br />
Tomek Kaczanowski</p>
]]></content:encoded>
	</item>
</channel>
</rss>

