<?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: One behavior != one assertion</title>
	<atom:link href="http://blog.agilephp.com/2009/02/21/one-behavior-one-assertion/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.agilephp.com/2009/02/21/one-behavior-one-assertion/</link>
	<description>Dagfinn Reiersøl on PHP, agile development, Ruby and other addictive substances</description>
	<lastBuildDate>Thu, 19 Jan 2012 18:39:47 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Buzz Lightyear is here &#187; Blog Archive &#187; links for 2011-06-06</title>
		<link>http://blog.agilephp.com/2009/02/21/one-behavior-one-assertion/comment-page-1/#comment-844</link>
		<dc:creator>Buzz Lightyear is here &#187; Blog Archive &#187; links for 2011-06-06</dc:creator>
		<pubDate>Mon, 06 Jun 2011 23:03:34 +0000</pubDate>
		<guid isPermaLink="false">http://blog.agilephp.com/?p=1483#comment-844</guid>
		<description>[...] One behavior != one assertion – PHP in Action (tags: php testing tdd phpunit unittesting bdd) [...]</description>
		<content:encoded><![CDATA[<p>[...] One behavior != one assertion – PHP in Action (tags: php testing tdd phpunit unittesting bdd) [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Thomas</title>
		<link>http://blog.agilephp.com/2009/02/21/one-behavior-one-assertion/comment-page-1/#comment-207</link>
		<dc:creator>Thomas</dc:creator>
		<pubDate>Sun, 22 Feb 2009 11:58:06 +0000</pubDate>
		<guid isPermaLink="false">http://blog.agilephp.com/?p=1483#comment-207</guid>
		<description>Oh and I forgot to ask, which codequote-plugin do you use?</description>
		<content:encoded><![CDATA[<p>Oh and I forgot to ask, which codequote-plugin do you use?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Thomas</title>
		<link>http://blog.agilephp.com/2009/02/21/one-behavior-one-assertion/comment-page-1/#comment-206</link>
		<dc:creator>Thomas</dc:creator>
		<pubDate>Sun, 22 Feb 2009 11:56:24 +0000</pubDate>
		<guid isPermaLink="false">http://blog.agilephp.com/?p=1483#comment-206</guid>
		<description>I agree! This kind of purism for purisms&#039; sake is just wasted time IMHO. I know not a whole lot agree here, but it is the same as with the whole CSS/table thing. Yes, okay, CSS *should* be used for layout (and of course that is my starting point), but sometimes it is just so much easier, quicker and consistent across browsers to just plug a table somewhere and be done with it. It may be an interesting exercise trying to get it just right in CSS, but frankly I like spending my time elsewhere and I&#039;m sure my clients agree..

Are you sure that is what he meant though? Comparing example #1 to #2 and calling #2 superior seems more than a little bit strange..</description>
		<content:encoded><![CDATA[<p>I agree! This kind of purism for purisms&#8217; sake is just wasted time IMHO. I know not a whole lot agree here, but it is the same as with the whole CSS/table thing. Yes, okay, CSS *should* be used for layout (and of course that is my starting point), but sometimes it is just so much easier, quicker and consistent across browsers to just plug a table somewhere and be done with it. It may be an interesting exercise trying to get it just right in CSS, but frankly I like spending my time elsewhere and I&#8217;m sure my clients agree..</p>
<p>Are you sure that is what he meant though? Comparing example #1 to #2 and calling #2 superior seems more than a little bit strange..</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Padraic Brady</title>
		<link>http://blog.agilephp.com/2009/02/21/one-behavior-one-assertion/comment-page-1/#comment-205</link>
		<dc:creator>Padraic Brady</dc:creator>
		<pubDate>Sun, 22 Feb 2009 11:50:03 +0000</pubDate>
		<guid isPermaLink="false">http://blog.agilephp.com/?p=1483#comment-205</guid>
		<description>Admittedly 1 Assertion == 1 Behaviour missed the whole test ;). That wasn&#039;t intentional though.

I think that we don&#039;t disagree to such a huge degree though - I made the point early on in the post: &quot;Now let me disclaim a little - I&#039;m really really sure there are times multiple assertions are needed. So my main point is not that this is an absolute rule with no possible exceptions so help me God, rather that it should be a rule unless you are literally forced to tackle an exception to it.&quot; You can read this as you suggested - it&#039;s a guideline with exceptions. My goal however is to make sure the exception is actually an exception, and not just an easy way out.

Your example can also be mangled a little differently. I agree (without reservation) that the example makes an excellent point but it also proves one of mine. If the product make ends up not being Logitech, there is no way for the test reporter to also tell us if the product model was also incorrect (or correct) since it&#039;s completely skipped over once the first assertion fails. This suggests the double assertion might be more informative (bearing in minds tests are documentation and should be as complete and as informative as possible) using a single assertion:

$this-&gt;assertEquals(
    array(&#039;Logitech&#039;, &#039;Harmony One&#039;),
    array($product-&gt;make, $product-&gt;model)
);

It might look longer (and it&#039;s cheating in one sense ;)), but it is one single assertion and PHPUnit will do something wonderful when it fails - it will print a diff of the two arrays to show where they differed. Now you will definitely see what happens when both Model properties, or only one, fail in contrast to your assertion twins.</description>
		<content:encoded><![CDATA[<p>Admittedly 1 Assertion == 1 Behaviour missed the whole test <img src='http://blog.agilephp.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> . That wasn&#8217;t intentional though.</p>
<p>I think that we don&#8217;t disagree to such a huge degree though &#8211; I made the point early on in the post: &#8220;Now let me disclaim a little &#8211; I&#8217;m really really sure there are times multiple assertions are needed. So my main point is not that this is an absolute rule with no possible exceptions so help me God, rather that it should be a rule unless you are literally forced to tackle an exception to it.&#8221; You can read this as you suggested &#8211; it&#8217;s a guideline with exceptions. My goal however is to make sure the exception is actually an exception, and not just an easy way out.</p>
<p>Your example can also be mangled a little differently. I agree (without reservation) that the example makes an excellent point but it also proves one of mine. If the product make ends up not being Logitech, there is no way for the test reporter to also tell us if the product model was also incorrect (or correct) since it&#8217;s completely skipped over once the first assertion fails. This suggests the double assertion might be more informative (bearing in minds tests are documentation and should be as complete and as informative as possible) using a single assertion:</p>
<p>$this-&gt;assertEquals(<br />
    array(&#8216;Logitech&#8217;, &#8216;Harmony One&#8217;),<br />
    array($product-&gt;make, $product-&gt;model)<br />
);</p>
<p>It might look longer (and it&#8217;s cheating in one sense <img src='http://blog.agilephp.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> ), but it is one single assertion and PHPUnit will do something wonderful when it fails &#8211; it will print a diff of the two arrays to show where they differed. Now you will definitely see what happens when both Model properties, or only one, fail in contrast to your assertion twins.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

