<?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: First Foray into Unit Testing with Visual Studio 2008</title>
	<atom:link href="http://www.developingfor.net/visual-studio/first-foray-into-unit-testing-with-visual-studio-2008.html/feed" rel="self" type="application/rss+xml" />
	<link>http://www.developingfor.net/visual-studio/first-foray-into-unit-testing-with-visual-studio-2008.html</link>
	<description>Real World .NET Methods, Tricks, and Examples</description>
	<lastBuildDate>Thu, 11 Mar 2010 18:24:27 -0500</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Dot Net Nerd</title>
		<link>http://www.developingfor.net/visual-studio/first-foray-into-unit-testing-with-visual-studio-2008.html/comment-page-1#comment-2495</link>
		<dc:creator>Dot Net Nerd</dc:creator>
		<pubDate>Mon, 01 Dec 2008 10:48:46 +0000</pubDate>
		<guid isPermaLink="false">http://www.developingfor.net/?p=99#comment-2495</guid>
		<description>&lt;strong&gt;Unit Testing in Visual Studio...&lt;/strong&gt;

Unit Testing in Visual Studio...</description>
		<content:encoded><![CDATA[<p><strong>Unit Testing in Visual Studio&#8230;</strong></p>
<p>Unit Testing in Visual Studio&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joel</title>
		<link>http://www.developingfor.net/visual-studio/first-foray-into-unit-testing-with-visual-studio-2008.html/comment-page-1#comment-573</link>
		<dc:creator>Joel</dc:creator>
		<pubDate>Tue, 12 Aug 2008 14:49:10 +0000</pubDate>
		<guid isPermaLink="false">http://www.developingfor.net/?p=99#comment-573</guid>
		<description>That&#039;s a great point Chris.  I&#039;m sure we all know that once we write it, it is ours forever (or at least as long as we work in the same place).

To be clear, though, this is what I said:

&lt;i&gt;...you would easily write tests to support or validate what you’ve already done. In my mind, that defeats the purpose.&lt;/i&gt;

What I mean by this is that when writing tests after the fact, we have to be careful to make sure they are testing the intent of the code and not just verifying the result we are already getting, since the two may not match.  I do agree that adding the tests has value, we just can&#039;t cook the testing books so to speak.</description>
		<content:encoded><![CDATA[<p>That&#8217;s a great point Chris.  I&#8217;m sure we all know that once we write it, it is ours forever (or at least as long as we work in the same place).</p>
<p>To be clear, though, this is what I said:</p>
<p><i>&#8230;you would easily write tests to support or validate what you’ve already done. In my mind, that defeats the purpose.</i></p>
<p>What I mean by this is that when writing tests after the fact, we have to be careful to make sure they are testing the intent of the code and not just verifying the result we are already getting, since the two may not match.  I do agree that adding the tests has value, we just can&#8217;t cook the testing books so to speak.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris Salter</title>
		<link>http://www.developingfor.net/visual-studio/first-foray-into-unit-testing-with-visual-studio-2008.html/comment-page-1#comment-572</link>
		<dc:creator>Chris Salter</dc:creator>
		<pubDate>Tue, 12 Aug 2008 14:25:58 +0000</pubDate>
		<guid isPermaLink="false">http://www.developingfor.net/?p=99#comment-572</guid>
		<description>One thing I&#039;d like to respond to in the comments here... Adding unit tests that validate what you&#039;ve already done doesn&#039;t defeat the purpose at all.  You might not be getting the full benefit, but it&#039;s still valuable.  If you ever have to come back to that code and make changes, having the tests gives you a much better chance of picking up any bugs you might happen to introduce.

If anything, my experience has been that in the long term, unit tests are really handy up-front but the real value is in the confidence they give you when you inevitably have to modify the code later... especially after your old, half-forgotten tests have caught a few bugs for you...</description>
		<content:encoded><![CDATA[<p>One thing I&#8217;d like to respond to in the comments here&#8230; Adding unit tests that validate what you&#8217;ve already done doesn&#8217;t defeat the purpose at all.  You might not be getting the full benefit, but it&#8217;s still valuable.  If you ever have to come back to that code and make changes, having the tests gives you a much better chance of picking up any bugs you might happen to introduce.</p>
<p>If anything, my experience has been that in the long term, unit tests are really handy up-front but the real value is in the confidence they give you when you inevitably have to modify the code later&#8230; especially after your old, half-forgotten tests have caught a few bugs for you&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Unit testing with Visual Studio 2008 - Part 2 &#171; Freekshow</title>
		<link>http://www.developingfor.net/visual-studio/first-foray-into-unit-testing-with-visual-studio-2008.html/comment-page-1#comment-115</link>
		<dc:creator>Unit testing with Visual Studio 2008 - Part 2 &#171; Freekshow</dc:creator>
		<pubDate>Thu, 26 Jun 2008 15:41:31 +0000</pubDate>
		<guid isPermaLink="false">http://www.developingfor.net/?p=99#comment-115</guid>
		<description>[...] A lot of times I&#8217;ve seen developers using a try/catch block to test for exceptions. Joel for example has posted this little code snippet: [...]</description>
		<content:encoded><![CDATA[<p>[...] A lot of times I&#8217;ve seen developers using a try/catch block to test for exceptions. Joel for example has posted this little code snippet: [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joel</title>
		<link>http://www.developingfor.net/visual-studio/first-foray-into-unit-testing-with-visual-studio-2008.html/comment-page-1#comment-99</link>
		<dc:creator>Joel</dc:creator>
		<pubDate>Thu, 19 Jun 2008 14:08:31 +0000</pubDate>
		<guid isPermaLink="false">http://www.developingfor.net/?p=99#comment-99</guid>
		<description>I think that&#039;s a big part of it Thomas. I frequently find myself starting to code with a rough idea of what I want, but without much of a game plan.  When I realize I&#039;m doing this, I try to stop and at least outline what it is I want to accomplish.  I think by writing the tests first, you start with two important pieces of information: the definition of success AND the definition of failure.  Since everything other than success constitutes failure, and we start without success, it makes sense to start with a failing test and code *just until* we achieve success.</description>
		<content:encoded><![CDATA[<p>I think that&#8217;s a big part of it Thomas. I frequently find myself starting to code with a rough idea of what I want, but without much of a game plan.  When I realize I&#8217;m doing this, I try to stop and at least outline what it is I want to accomplish.  I think by writing the tests first, you start with two important pieces of information: the definition of success AND the definition of failure.  Since everything other than success constitutes failure, and we start without success, it makes sense to start with a failing test and code *just until* we achieve success.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Thomas Eyde</title>
		<link>http://www.developingfor.net/visual-studio/first-foray-into-unit-testing-with-visual-studio-2008.html/comment-page-1#comment-96</link>
		<dc:creator>Thomas Eyde</dc:creator>
		<pubDate>Thu, 19 Jun 2008 13:50:39 +0000</pubDate>
		<guid isPermaLink="false">http://www.developingfor.net/?p=99#comment-96</guid>
		<description>I read the other day, I don&#039;t remember exactly where, but it said that writing tests first make us focusing better on the task at hand, and that activity alone makes the quality go up by an order of magnitude.</description>
		<content:encoded><![CDATA[<p>I read the other day, I don&#8217;t remember exactly where, but it said that writing tests first make us focusing better on the task at hand, and that activity alone makes the quality go up by an order of magnitude.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dan Blair</title>
		<link>http://www.developingfor.net/visual-studio/first-foray-into-unit-testing-with-visual-studio-2008.html/comment-page-1#comment-79</link>
		<dc:creator>Dan Blair</dc:creator>
		<pubDate>Mon, 16 Jun 2008 16:44:15 +0000</pubDate>
		<guid isPermaLink="false">http://www.developingfor.net/?p=99#comment-79</guid>
		<description>The just in case methods are the first things that I saw go when we started focusing on using unit tests.  If you write what you need, you know when your done, have a reasonable expectation of it being correct, and the code should be more maintainable.

I come across code all the time that&#039;s 8 year old &quot;just in case&quot; code that has never been used.  Some of it took several weeks/months to develop, we really do nobody a service by creating such things.</description>
		<content:encoded><![CDATA[<p>The just in case methods are the first things that I saw go when we started focusing on using unit tests.  If you write what you need, you know when your done, have a reasonable expectation of it being correct, and the code should be more maintainable.</p>
<p>I come across code all the time that&#8217;s 8 year old &#8220;just in case&#8221; code that has never been used.  Some of it took several weeks/months to develop, we really do nobody a service by creating such things.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joel</title>
		<link>http://www.developingfor.net/visual-studio/first-foray-into-unit-testing-with-visual-studio-2008.html/comment-page-1#comment-78</link>
		<dc:creator>Joel</dc:creator>
		<pubDate>Mon, 16 Jun 2008 13:02:07 +0000</pubDate>
		<guid isPermaLink="false">http://www.developingfor.net/?p=99#comment-78</guid>
		<description>Oh, I like that!  Yes, I have plenty to learn.  I don&#039;t think adding them after the fact is difficult, per se, but I can see where you would easily write tests to support or validate what you&#039;ve already done.  In my mind, that defeats the purpose.

Also, one of the articles I read mentioned that by using TDD, you only develop the code you need.  I have a tendency to write a bunch of overloads and methods &quot;just in case&quot;, so this will be a great benefit for me.  I think ultimately it will make me a faster coder, and I&#039;m sure a more productive one.</description>
		<content:encoded><![CDATA[<p>Oh, I like that!  Yes, I have plenty to learn.  I don&#8217;t think adding them after the fact is difficult, per se, but I can see where you would easily write tests to support or validate what you&#8217;ve already done.  In my mind, that defeats the purpose.</p>
<p>Also, one of the articles I read mentioned that by using TDD, you only develop the code you need.  I have a tendency to write a bunch of overloads and methods &#8220;just in case&#8221;, so this will be a great benefit for me.  I think ultimately it will make me a faster coder, and I&#8217;m sure a more productive one.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Thomas Eyde</title>
		<link>http://www.developingfor.net/visual-studio/first-foray-into-unit-testing-with-visual-studio-2008.html/comment-page-1#comment-76</link>
		<dc:creator>Thomas Eyde</dc:creator>
		<pubDate>Sat, 14 Jun 2008 18:00:46 +0000</pubDate>
		<guid isPermaLink="false">http://www.developingfor.net/?p=99#comment-76</guid>
		<description>As you have discovered, adding unit tests after the fact is very hard work. I can tell you, once you get the habit of writing them first, one by one, you will find them easy to write and quite indispensable.

A tip for the tests you have shown us here: 

The assertion message is only displayed when something is broken, hence you want the message to explain what&#039;s wrong. The way you have written these tests, the second assertion will always be true and the message never displayed.

If you are comfortable with empty catches, you can just delete the second assertion.

If the exception type is important, you could write the test as follows:

[TestMethod]
public void TestZipCodeNumericButGreaterThan99999()
{
    TransactionRequestInfo req = new TransactionRequestInfo();
    string testValue = &quot;58634789&quot;;
    
    ArgumentException thrownException = null;
    try
    {
        req.Zip = testValue;
    }
    catch (ArgumentException aex)
    {
        thrownException = aex;
    }

    Assert.IsNotNull(thrownException, &quot;Proper exception not thrown.&quot;);
}</description>
		<content:encoded><![CDATA[<p>As you have discovered, adding unit tests after the fact is very hard work. I can tell you, once you get the habit of writing them first, one by one, you will find them easy to write and quite indispensable.</p>
<p>A tip for the tests you have shown us here: </p>
<p>The assertion message is only displayed when something is broken, hence you want the message to explain what&#8217;s wrong. The way you have written these tests, the second assertion will always be true and the message never displayed.</p>
<p>If you are comfortable with empty catches, you can just delete the second assertion.</p>
<p>If the exception type is important, you could write the test as follows:</p>
<p>[TestMethod]<br />
public void TestZipCodeNumericButGreaterThan99999()<br />
{<br />
    TransactionRequestInfo req = new TransactionRequestInfo();<br />
    string testValue = &#8220;58634789&#8243;;</p>
<p>    ArgumentException thrownException = null;<br />
    try<br />
    {<br />
        req.Zip = testValue;<br />
    }<br />
    catch (ArgumentException aex)<br />
    {<br />
        thrownException = aex;<br />
    }</p>
<p>    Assert.IsNotNull(thrownException, &#8220;Proper exception not thrown.&#8221;);<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joel</title>
		<link>http://www.developingfor.net/visual-studio/first-foray-into-unit-testing-with-visual-studio-2008.html/comment-page-1#comment-74</link>
		<dc:creator>Joel</dc:creator>
		<pubDate>Fri, 13 Jun 2008 13:53:19 +0000</pubDate>
		<guid isPermaLink="false">http://www.developingfor.net/?p=99#comment-74</guid>
		<description>Thanks, I&#039;ll be sure to read it.

Even with my extremely limited experimentation I can see that they are going to become a staple of my development diet.  I know there are people who are diehard NUnit fans, but I&#039;m sure it really doesn&#039;t matter what flavor you prefer.  For me, I&#039;ll probably stick with the built in Testing mechanism, just because it is easy and readily available.</description>
		<content:encoded><![CDATA[<p>Thanks, I&#8217;ll be sure to read it.</p>
<p>Even with my extremely limited experimentation I can see that they are going to become a staple of my development diet.  I know there are people who are diehard NUnit fans, but I&#8217;m sure it really doesn&#8217;t matter what flavor you prefer.  For me, I&#8217;ll probably stick with the built in Testing mechanism, just because it is easy and readily available.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
