<?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: Assertions: actual or expected first?</title>
	<atom:link href="http://grahamis.com/blog/2009/06/05/assertions_actual_or_expected_first/feed/" rel="self" type="application/rss+xml" />
	<link>http://grahamis.com/blog/2009/06/05/assertions_actual_or_expected_first/</link>
	<description>It&#039;s too real to be true</description>
	<lastBuildDate>Sat, 07 May 2011 05:40:39 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Srushti</title>
		<link>http://grahamis.com/blog/2009/06/05/assertions_actual_or_expected_first/comment-page-1/#comment-435</link>
		<dc:creator>Srushti</dc:creator>
		<pubDate>Sat, 06 Jun 2009 06:39:19 +0000</pubDate>
		<guid isPermaLink="false">http://grahamis.com/blog/2009/06/05/assertions_actual_or_expected_first/#comment-435</guid>
		<description>On my last project (.net) I created extension methods for assertions as a wrapper around NUnit assertions.

public static void ShouldBe(this T actual, T expected);

The assertions would then read x.ShouldBe(20).

You can also extend this by adding other methods for other assertions:

public static void ShouldBeTrue(this bool actual);

public static void ShouldBeAtLeast(this int actual, int expected);

...and so on.</description>
		<content:encoded><![CDATA[<p>On my last project (.net) I created extension methods for assertions as a wrapper around NUnit assertions.</p>
<p>public static void ShouldBe(this T actual, T expected);</p>
<p>The assertions would then read x.ShouldBe(20).</p>
<p>You can also extend this by adding other methods for other assertions:</p>
<p>public static void ShouldBeTrue(this bool actual);</p>
<p>public static void ShouldBeAtLeast(this int actual, int expected);</p>
<p>&#8230;and so on.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nick Drew</title>
		<link>http://grahamis.com/blog/2009/06/05/assertions_actual_or_expected_first/comment-page-1/#comment-434</link>
		<dc:creator>Nick Drew</dc:creator>
		<pubDate>Sat, 06 Jun 2009 03:28:06 +0000</pubDate>
		<guid isPermaLink="false">http://grahamis.com/blog/2009/06/05/assertions_actual_or_expected_first/#comment-434</guid>
		<description>So in (rspec originated) BDD we have  should matcher
In hamcrest we have assertthat( actual, matcher )
In old Junit we have Assert( expected, actual )
In mstest we have a mix of Assert( actual, expected ) and CollectionsAssert.Contains( actual, element )

All pretty inconsistent.

I have to say that I may I find it easier to maintain complex assertions with the matcher syntax.
For complex document traversals, I may start of with:

assertThat( document, hasXPath( &quot;//book[@title=&#039;&quot; + expected_title + &quot;&#039;] ))

but after writing too many very similar xpath expressions,  I may find myself with the following:

assertThat( document, hasBook( hasTitle( expected_title ), hasAuthor( expected_author ) )

I find that evolution very powerful, and I find it more convenient to keep the actual values lined up on the left side while the equivalence classes/matchers fluctutate on the right hand side.</description>
		<content:encoded><![CDATA[<p>So in (rspec originated) BDD we have  should matcher<br />
In hamcrest we have assertthat( actual, matcher )<br />
In old Junit we have Assert( expected, actual )<br />
In mstest we have a mix of Assert( actual, expected ) and CollectionsAssert.Contains( actual, element )</p>
<p>All pretty inconsistent.</p>
<p>I have to say that I may I find it easier to maintain complex assertions with the matcher syntax.<br />
For complex document traversals, I may start of with:</p>
<p>assertThat( document, hasXPath( &#8220;//book[@title='" + expected_title + "'] ))</p>
<p>but after writing too many very similar xpath expressions,  I may find myself with the following:</p>
<p>assertThat( document, hasBook( hasTitle( expected_title ), hasAuthor( expected_author ) )</p>
<p>I find that evolution very powerful, and I find it more convenient to keep the actual values lined up on the left side while the equivalence classes/matchers fluctutate on the right hand side.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

