<?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>Randy Patterson &#187; What Burns Me</title>
	<atom:link href="http://RandyPatterson.com/index.php/category/what-burns-me/feed/" rel="self" type="application/rss+xml" />
	<link>http://RandyPatterson.com</link>
	<description>Code To Live, Live To Code</description>
	<lastBuildDate>Sat, 24 Apr 2010 01:18:12 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Useless Unit Test</title>
		<link>http://RandyPatterson.com/index.php/2007/09/21/useless-unit-test/</link>
		<comments>http://RandyPatterson.com/index.php/2007/09/21/useless-unit-test/#comments</comments>
		<pubDate>Fri, 21 Sep 2007 12:10:15 +0000</pubDate>
		<dc:creator>randypatterson</dc:creator>
				<category><![CDATA[What Burns Me]]></category>

		<guid isPermaLink="false">http://localhost/2007/09/21/UselessUnitTest.aspx</guid>
		<description><![CDATA[This is one of the most useless unit tests I&#8217;ve encountered





/// &#60;summary&#62;
///A test for GetByLegalCaseID (int)
///&#60;/summary&#62;
[TestMethod()]
public void GetTicketByLegalCaseID_Test()
{
    TicketEntityModel target = new TicketEntityModel();
    int ID = 1;
    TicketDataSet actual = target.GetByLegalCaseID(ID);
&#160;
    Assert.IsNotNull(actual, "TicketDataSet was not returned.");
    Assert.IsNotNull(actual.Citation, "No Citation table [...]]]></description>
			<content:encoded><![CDATA[<p>This is one of the most useless unit tests I&#8217;ve encountered</p>
<table cellspacing="0" cellpadding="2" width="611" border="1">
<tbody>
<tr>
<td valign="top" width="609">
<div class="csharpcode">
<pre class="alt"><span class="rem">/// &lt;summary&gt;</span></pre>
<pre><span class="rem">///A test for GetByLegalCaseID (int)</span></pre>
<pre class="alt"><span class="rem">///&lt;/summary&gt;</span></pre>
<pre>[TestMethod()]</pre>
<pre class="alt"><span class="kwrd">public</span> <span class="kwrd">void</span> GetTicketByLegalCaseID_Test()</pre>
<pre>{</pre>
<pre class="alt">    TicketEntityModel target = <span class="kwrd">new</span> TicketEntityModel();</pre>
<pre>    <span class="kwrd">int</span> ID = 1;</pre>
<pre class="alt">    TicketDataSet actual = target.GetByLegalCaseID(ID);</pre>
<pre>&nbsp;</pre>
<pre class="alt">    Assert.IsNotNull(actual, <span class="str">"TicketDataSet was not returned."</span>);</pre>
<pre>    Assert.IsNotNull(actual.Citation, <span class="str">"No Citation table was returned."</span>);</pre>
<pre class="alt">    Assert.IsTrue(actual.Citation.Rows.Count &gt; 0, <span class="str">"No Citation rows were returned."</span>);</pre>
<pre>    Assert.IsNotNull(actual.Ticket, <span class="str">"No Ticket table was returned."</span>);</pre>
<pre class="alt">    Assert.IsTrue(actual.Ticket.Rows.Count &gt; 0, <span class="str">"No Ticket rows were returned."</span>);</pre>
<pre>}</pre>
</div>
<style type="text/css">.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
</style>
</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<p>Unit tests in the Entity Model should concentrate on testing business logic, not Data Access Layer (<span class="acronym" title="Data Access Layer">DAL</span>) logic. Unit tests for <span class="acronym" title="Data Access Layer">DAL</span> objects test data access issues.&nbsp;&nbsp; Furthermore,&nbsp; this Unit Test simply checks to see if the current database has a record with an ID of 1 and, therefore, is non-deterministic. It can fail for <strong>many</strong> reasons that have nothing to do with the business logic. If <em>GetByLegalCaseID</em> has any business logic in it then unit tests should to be written to test that logic and the dependencies on the <span class="acronym" title="Data Access Layer">DAL</span> would be mocked so a previously setup DataSet is returned with known values. This falls under the &#8220;What Burns Me&#8221; category.&nbsp; </p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a><strong><em>Bookmark It</em></strong></a>
<br />
<div class="d">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http://RandyPatterson.com/index.php/2007/09/21/useless-unit-test/&amp;title=Useless+Unit+Test" rel="nofollow" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://RandyPatterson.com/wp-content/plugins/social-bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http://RandyPatterson.com/index.php/2007/09/21/useless-unit-test/&amp;title=Useless+Unit+Test" rel="nofollow" title="Add to&nbsp;digg"><img class="social_img" src="http://RandyPatterson.com/wp-content/plugins/social-bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.dotnetkicks.com/kick/?url=http://RandyPatterson.com/index.php/2007/09/21/useless-unit-test/&amp;title=Useless+Unit+Test" rel="nofollow" title="Add to&nbsp;DotNetKicks"><img class="social_img" src="http://RandyPatterson.com/wp-content/plugins/social-bookmarks/images/dotnetkicks.png" title="Add to&nbsp;DotNetKicks" alt="Add to&nbsp;DotNetKicks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.dzone.com/links/add.html?description=Useless+Unit+Test&amp;url=http://RandyPatterson.com/index.php/2007/09/21/useless-unit-test/&amp;title=Useless+Unit+Test" rel="nofollow" title="Add to&nbsp;DZone"><img class="social_img" src="http://RandyPatterson.com/wp-content/plugins/social-bookmarks/images/dzone.png" title="Add to&nbsp;DZone" alt="Add to&nbsp;DZone" /></a>
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http://RandyPatterson.com/index.php/2007/09/21/useless-unit-test/&amp;title=Useless+Unit+Test" rel="nofollow" title="Add to&nbsp;Google Bookmarks"><img class="social_img" src="http://RandyPatterson.com/wp-content/plugins/social-bookmarks/images/google.png" title="Add to&nbsp;Google Bookmarks" alt="Add to&nbsp;Google Bookmarks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http://RandyPatterson.com/index.php/2007/09/21/useless-unit-test/&amp;title=Useless+Unit+Test" rel="nofollow" title="Add to&nbsp;reddit"><img class="social_img" src="http://RandyPatterson.com/wp-content/plugins/social-bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://slashdot.org/bookmark.pl?url=http://RandyPatterson.com/index.php/2007/09/21/useless-unit-test/&amp;title=Useless+Unit+Test" rel="nofollow" title="Add to&nbsp;Slashdot"><img class="social_img" src="http://RandyPatterson.com/wp-content/plugins/social-bookmarks/images/slashdot.png" title="Add to&nbsp;Slashdot" alt="Add to&nbsp;Slashdot" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit.php?url=http://RandyPatterson.com/index.php/2007/09/21/useless-unit-test/&amp;title=Useless+Unit+Test" rel="nofollow" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://RandyPatterson.com/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http://RandyPatterson.com/index.php/2007/09/21/useless-unit-test/" rel="nofollow" title="Add to&nbsp;Technorati"><img class="social_img" src="http://RandyPatterson.com/wp-content/plugins/social-bookmarks/images/technorati.png" title="Add to&nbsp;Technorati" alt="Add to&nbsp;Technorati" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://twitter.com/home/?status=Check+out+Useless+Unit+Test+@+http://RandyPatterson.com/index.php/2007/09/21/useless-unit-test/" rel="nofollow" title="Add to&nbsp;Twitter"><img class="social_img" src="http://RandyPatterson.com/wp-content/plugins/social-bookmarks/images/twitter.png" title="Add to&nbsp;Twitter" alt="Add to&nbsp;Twitter" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http://RandyPatterson.com/index.php/2007/09/21/useless-unit-test/&amp;t=Useless+Unit+Test" rel="nofollow" title="Add to&nbsp;Yahoo My Web"><img class="social_img" src="http://RandyPatterson.com/wp-content/plugins/social-bookmarks/images/yahoo.png" title="Add to&nbsp;Yahoo My Web" alt="Add to&nbsp;Yahoo My Web" /></a>
<br />
</div>
</div>
<!-- Social Bookmarks END -->
]]></content:encoded>
			<wfw:commentRss>http://RandyPatterson.com/index.php/2007/09/21/useless-unit-test/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>
