<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Waving Furiously &#187; testing</title>
	<atom:link href="http://reflectionsofmind.info/blog/tag/testing/feed/" rel="self" type="application/rss+xml" />
	<link>http://reflectionsofmind.info/blog</link>
	<description>About Java and other stuff</description>
	<lastBuildDate>Mon, 05 Oct 2009 09:28:15 +0000</lastBuildDate>
	
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Tests shouldn&#8217;t mirror the application</title>
		<link>http://reflectionsofmind.info/blog/2009/10/05/tests-shouldnt-mirror-the-application/</link>
		<comments>http://reflectionsofmind.info/blog/2009/10/05/tests-shouldnt-mirror-the-application/#comments</comments>
		<pubDate>Mon, 05 Oct 2009 08:51:22 +0000</pubDate>
		<dc:creator>Tymur Porkuian</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[FitNesse]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://reflectionsofmind.info/blog/?p=1025</guid>
		<description><![CDATA[Some time ago I&#8217;ve created a suite of (FitNesse) acceptance tests for the app we are working on. Some of them were of the form of:
Given that a customer exists with customer name "John"
Given that a search results page is displayed for search criteria customer name "John"
Then at least one one customer should be displayed
Our [...]]]></description>
			<content:encoded><![CDATA[<p>Some time ago I&#8217;ve created a suite of (<a href="http://fitnesse.org/">FitNesse</a>) acceptance tests for the app we are working on. Some of them were of the form of:<br />
<code>Given that a customer exists with customer name "John"<br />
Given that a search results page is displayed for search criteria customer name "John"<br />
Then at least one one customer should be displayed</code></p>
<p>Our QA (correctly) noted that this test is far from perfect because it doesn&#8217;t check that the found customer is the one with name &#8220;John&#8221;. On the other hand, there could be more than customer with this name. This means that we should not only verify that <em>all found customers have the name &#8220;John&#8221;</em>, but also that <em>we have found all customers with such name</em>. So we should first look into the database to find out what customers should be in the list and then check that we display only them. Correct? <em>No!</em></p>
<p>The problem with this approach is that the test starts to mirror the application. It queries the database for customers with the name &#8220;John&#8221; &#8211; but isn&#8217;t this what the app does? If we made some mistakes in the app when implementing the query in the app, then who can guarantee that we won&#8217;t make the same mistakes when implementing that same query in the test? </p>
<p>So we limited ourselves with this:<br />
<code>Given that a customer exists with customer id "mock-customer-1" and name "John" and surname "Smith"<br />
Given that a search results page is displayed for search criteria id "mock-customer-1"<br />
Then at least one one customer should be displayed with name "John" and surname "Smith"<br />
And no customers should be displayed that don't have name "John" and surname "Smith"</code></p>
<p>Yes, this test does not verify that we found all the customers we searched for, but the only test that verifies application completely would be the application itself. Tests should be a stabilizing harness, not a copy, otherwise there&#8217;s no point in writing them.</p>
]]></content:encoded>
			<wfw:commentRss>http://reflectionsofmind.info/blog/2009/10/05/tests-shouldnt-mirror-the-application/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
