<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://devlicio.us/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Derik Whittaker : TDD</title><link>http://devlicio.us/blogs/derik_whittaker/archive/tags/TDD/default.aspx</link><description>Tags: TDD</description><dc:language>en</dc:language><generator>CommunityServer 2008.5 SP1 (Build: 31106.3070)</generator><item><title>Running Typescript tests via Jasmine and Chutzpah on Teamcity</title><link>http://devlicio.us/blogs/derik_whittaker/archive/2012/12/25/running-typescript-tests-via-jasmine-and-chutzpah-on-teamcity.aspx</link><pubDate>Wed, 26 Dec 2012 00:54:27 GMT</pubDate><guid isPermaLink="false">40756a8b-6212-4073-9d98-6c26781577de:70734</guid><dc:creator>Derik Whittaker</dc:creator><slash:comments>11</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://devlicio.us/blogs/derik_whittaker/rsscomments.aspx?PostID=70734</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://devlicio.us/blogs/derik_whittaker/commentapi.aspx?PostID=70734</wfw:comment><comments>http://devlicio.us/blogs/derik_whittaker/archive/2012/12/25/running-typescript-tests-via-jasmine-and-chutzpah-on-teamcity.aspx#comments</comments><description>&lt;p&gt;In my prior post I talked about how I setup my environment for testing my Typescript source via Jasmine and &lt;a href="http://chutzpah.codeplex.com/"&gt;Chutzpah&lt;/a&gt;.&amp;#160; That was just the beginning.&amp;#160; Now that I had the ability to create unit tests I needed the ability to run them on our CI server, which happens to be &lt;a&gt;Teamcity&lt;/a&gt;).&amp;#160; I did a bunch of looking around and could not find anything that seemed to work for me, but I did notice that Chutzpah had the ability to run via the command line… GOLD.&lt;/p&gt;  &lt;p&gt;Armed w/ the knowledge that I can run my tests from the command line I gave it a whirl.&amp;#160; After looking at the docs it appeared I could run get the results I wanted w/ the following.&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;chutzpah.console.exe /path “c:\path_to_my_typescript_folder_here /teamcity&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;However, when I ran the above command I got the following output&lt;/p&gt;  &lt;p&gt;&lt;a href="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_2387311E.png"&gt;&lt;img style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" title="image" border="0" alt="image" src="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_thumb_5F00_132BB965.png" width="387" height="118" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;If you look at the above you will see 33 total test, 22 failures.&amp;#160; This is odd because I only have 11 tests.&amp;#160; Turns out the command line tool is running my .js files (ones generated via Typescript) and my .ts files. I only wanted to run my .ts files.&amp;#160; I figured there had to be a command line switch, but there was not.&amp;#160; This sucked because inside of Visual Studio i can set it to ONLY run typescript files as seen below.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_59A8A96D.png"&gt;&lt;img style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" title="image" border="0" alt="image" src="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_thumb_5F00_26D8A2F9.png" width="559" height="138" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;I figured I would take a peek at the source to see if I could add support for TestingMode via the command line, turns out I could (side note, I created a fork &lt;a href="http://chutzpah.codeplex.com/SourceControl/network/forks/dwhittaker/TypescriptChanges"&gt;here&lt;/a&gt; and have submitted a &lt;a href="http://chutzpah.codeplex.com/SourceControl/network/forks/dwhittaker/TypescriptChanges/contribution/3848"&gt;pull request&lt;/a&gt; for my changes so i hope they are consumed soon)&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;Now I can run the command w/ the new “/TestMode Typescript” option as below&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;chutzpah.console.exe /path “c:\path_to_my_typescript_folder_here /testMode TypeScript /teamcity&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;When I run the above command I get below&lt;/p&gt;  &lt;p&gt;&lt;a href="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_26003D0F.png"&gt;&lt;img style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" title="image" border="0" alt="image" src="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_thumb_5F00_3E8FDA5F.png" width="376" height="110" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;With my commits you will see the /testmode option via the help as below&lt;/p&gt;  &lt;p&gt;&lt;a href="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_7DED8DEF.png"&gt;&lt;img style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" title="image" border="0" alt="image" src="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_thumb_5F00_0A7B3B0C.png" width="899" height="250" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Once I had a working version of Chutzpah which can output my test results all I needed to do was add it to my build script (we use &lt;a href="https://github.com/JamesKovacs/psake"&gt;pSake&lt;/a&gt;) and bam, I now have Typescript/Javascript tests showing up in my Teamcity builds as seen below&lt;/p&gt;  &lt;p&gt;&lt;a href="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_5BB58269.png"&gt;&lt;img style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" title="image" border="0" alt="image" src="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_thumb_5F00_22327272.png" width="289" height="72" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;or as shown from from our Teamcity logs&lt;/p&gt;  &lt;p&gt;&lt;a href="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_53BDE007.png"&gt;&lt;img style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" title="image" border="0" alt="image" src="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_thumb_5F00_2C1763DD.png" width="391" height="241" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Hope this helps&lt;/p&gt;  &lt;p&gt;Till Next Time,&lt;/p&gt;  &lt;p&gt;P.S. If you need a copy of my .exe before my changes are added to the master branch let me know.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devlicio.us/aggbug.aspx?PostID=70734" width="1" height="1"&gt;</description><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/TDD/default.aspx">TDD</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/Typescript/default.aspx">Typescript</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/Chutzpah/default.aspx">Chutzpah</category></item><item><title>Setting up Unit Testing w/ Jasmine, Chutzpah and Typescript</title><link>http://devlicio.us/blogs/derik_whittaker/archive/2012/12/23/setting-up-unit-testing-w-jasmine-chutzpah-and-typescript.aspx</link><pubDate>Sun, 23 Dec 2012 12:49:46 GMT</pubDate><guid isPermaLink="false">40756a8b-6212-4073-9d98-6c26781577de:70731</guid><dc:creator>Derik Whittaker</dc:creator><slash:comments>2</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://devlicio.us/blogs/derik_whittaker/rsscomments.aspx?PostID=70731</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://devlicio.us/blogs/derik_whittaker/commentapi.aspx?PostID=70731</wfw:comment><comments>http://devlicio.us/blogs/derik_whittaker/archive/2012/12/23/setting-up-unit-testing-w-jasmine-chutzpah-and-typescript.aspx#comments</comments><description>&lt;p&gt;Recently I got back into writing html/javascript code as part of my day job and boy-o-boy have things changed since the last time i did any of this.&amp;#160; One thing that has not changed for me however was my belief in unit testing, so it was very painful for me to be writing hundreds of lines of javascript (ok really &lt;a&gt;TypeScript&lt;/a&gt;) code with NO tests supporting them.&amp;#160; At first I was able to live with this feeling because I was too busy trying to relearn how to do javascript development.&amp;#160; However, I have not reached a comfort level where the lack of tests is killing me again.&lt;/p&gt;  &lt;p&gt;No of course in client/server land of .Net development getting started testing is dead simple, however in the Javascript/html world things are still in the toddler stage, IMO, and there are many, many options to testing and I had no idea which is the best.&amp;#160; After doing some searching and asking on twitter I settled on Jasmine as my test runner.&amp;#160; &lt;/p&gt;  &lt;p&gt;Now that I picked Jasmine, how did I get started?&amp;#160; Here is what I did (this post is a merging of many, many posts I looked at to get me pointed in the right direction)&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Step 1: Create a new test project&lt;/strong&gt;&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;Open up Visual Studio 2012 and create a basic MVC 4 application (empty)      &lt;br /&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;&lt;strong&gt;Step 2: Get &lt;/strong&gt;&lt;a href="http://pivotal.github.com/jasmine/"&gt;&lt;strong&gt;Jasmine&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;Install the Jasmine NuGet Package      &lt;br /&gt;&lt;a href="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_28E3288F.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="image" border="0" alt="image" src="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_thumb_5F00_4CBBDA1C.png" width="751" height="99" /&gt;&lt;/a&gt;       &lt;br /&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;&lt;strong&gt;Step 3: Run your application in order to validate that jasmine is running correctly&lt;/strong&gt;&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_5302B0AA.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="image" border="0" alt="image" src="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_thumb_5F00_3CCC9558.png" width="448" height="309" /&gt;&lt;/a&gt; &lt;/p&gt;    &lt;p&gt;Yup, we are good      &lt;br /&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;&lt;strong&gt;Step 4: Get &lt;/strong&gt;&lt;a href="http://chutzpah.codeplex.com/"&gt;&lt;strong&gt;Chutzpah&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;I wanted a way to run my tests inside of Visual Studio and this plugin seemed to do the trick. I opted to install the test adapter which can be found &lt;a href="http://visualstudiogallery.msdn.microsoft.com/f8741f04-bae4-4900-81c7-7c9bfb9ed1fe"&gt;here&lt;/a&gt;       &lt;br /&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;&lt;strong&gt;Step 5: Validate that Chutzpah adapter was setup correctly&lt;/strong&gt;&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_69E18226.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="image" border="0" alt="image" src="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_thumb_5F00_572C886F.png" width="562" height="170" /&gt;&lt;/a&gt; &lt;/p&gt;    &lt;p&gt;As you can see from above, it is setup correctly.&lt;/p&gt;    &lt;p&gt;Now I wanted to be able to author my tests in Typescript and have them run as well.      &lt;br /&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;&lt;strong&gt;Step 6: Download the Jasmine &lt;/strong&gt;&lt;a href="https://github.com/borisyankov/DefinitelyTyped/tree/master/jasmine"&gt;&lt;strong&gt;typescript definition file&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt;.&amp;#160; I put this inside my scripts folder as seen below&lt;/strong&gt;&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;a href="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_1A9489D2.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="image" border="0" alt="image" src="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_thumb_5F00_27FA9CD8.png" width="245" height="101" /&gt;&lt;/a&gt;       &lt;br /&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;&lt;strong&gt;Step 7: Create my Test Spec&lt;/strong&gt;&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;The trick to getting this to work of course is that I need to include the jasmine-1.2.d.ts definition file inside my .ts file as below&lt;/p&gt;    &lt;p&gt;&lt;a href="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_206F2D6B.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="image" border="0" alt="image" src="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_thumb_5F00_2002FA76.png" width="345" height="28" /&gt;&lt;/a&gt; &lt;/p&gt;    &lt;p&gt;I also need to reference my class under test file inside my .ts file as below&lt;/p&gt;    &lt;p&gt;&lt;a href="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_389297C6.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="image" border="0" alt="image" src="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_thumb_5F00_5EF47B11.png" width="289" height="39" /&gt;&lt;/a&gt; &lt;/p&gt;    &lt;p&gt;Once I did both of these I could write my first test as below&lt;/p&gt;    &lt;p&gt;&lt;a href="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_05565E5D.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="image" border="0" alt="image" src="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/image_5F00_thumb_5F00_44B411ED.png" width="322" height="175" /&gt;&lt;/a&gt;&amp;#160;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;Bam, now I have a jasmine test written via Typescript and runnable via the Chutzpah test running.&amp;#160; Of course I am sure there are other ways to get this to work, this is just what worked for me.&lt;/p&gt;  &lt;p&gt;Till next time,&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devlicio.us/aggbug.aspx?PostID=70731" width="1" height="1"&gt;</description><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/TDD/default.aspx">TDD</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/HowTo/default.aspx">HowTo</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/JavaScript/default.aspx">JavaScript</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/Typescript/default.aspx">Typescript</category></item><item><title>Unit Testing Silverlight from MSTest–Forcing VS to use the right Silverlight Assemblies</title><link>http://devlicio.us/blogs/derik_whittaker/archive/2011/08/26/unit-testing-silverlight-from-mstest.aspx</link><pubDate>Fri, 26 Aug 2011 13:13:14 GMT</pubDate><guid isPermaLink="false">40756a8b-6212-4073-9d98-6c26781577de:68139</guid><dc:creator>Derik Whittaker</dc:creator><slash:comments>3</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://devlicio.us/blogs/derik_whittaker/rsscomments.aspx?PostID=68139</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://devlicio.us/blogs/derik_whittaker/commentapi.aspx?PostID=68139</wfw:comment><comments>http://devlicio.us/blogs/derik_whittaker/archive/2011/08/26/unit-testing-silverlight-from-mstest.aspx#comments</comments><description>&lt;p&gt;Ok, silverlight and unit testing just plan sucks, I firmly believe that the devs for silverlight did NOT care about testability, but that is off topic.&amp;#160; When doing any type of unit testing (and not with the built in silverlight testing framework which actually runs the app, talking code level testing) you will quickly run into an issue of version mis-match.&lt;/p&gt;  &lt;p&gt;The issue with the version mis-match is that VS wants to push the 4.0 version of your assemblies, even when you add direct reference to the 2.0.5 version (silverlight version).&amp;#160; When this happens your tests will fail with an error telling you that your assemblies are not the right version.&amp;#160; And if you are like me you will try over and over to ‘force’ vs to reference the right version and it will fail.&amp;#160; The good news is that there IS a way around this, but it is a bit of a hack&lt;/p&gt;  &lt;p&gt;How to get around this issue (at least one way)&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Move copies of your desired Silverlight .dlls into a local library folder. I have the following in my folder      &lt;ol&gt;       &lt;li&gt;System.ComponentModel.DataAnnotations.dll &lt;/li&gt;        &lt;li&gt;System.Net.dll &lt;/li&gt;        &lt;li&gt;System.Runtime.Serialization.dll &lt;/li&gt;        &lt;li&gt;System.ServiceModel.dll &lt;/li&gt;        &lt;li&gt;System.ServiceModel.DomainServices.Client.dll &lt;/li&gt;        &lt;li&gt;System.Windows.dll &lt;/li&gt;        &lt;li&gt;System.Xml.dll &lt;/li&gt;     &lt;/ol&gt;   &lt;/li&gt;    &lt;li&gt;Open up your unit tests .proj file in notepad or any text editor &lt;/li&gt;    &lt;ol&gt;     &lt;li&gt;Find the &amp;lt;Reference&amp;gt; entry to the correct silverlight dll you want and create a hint path which points to your LOCAL dll        &lt;br /&gt;See this example:         &lt;br /&gt;&amp;lt;Reference Include=&amp;quot;System.ServiceModel&amp;quot;&amp;gt;         &lt;br /&gt;&amp;#160; &amp;lt;HintPath&amp;gt;..\..\..\Libraries\Silverlight Test dlls\2.0.5 DLLs\System.ServiceModel.dll&amp;lt;/HintPath&amp;gt;         &lt;br /&gt;&amp;lt;/Reference&amp;gt;         &lt;br /&gt;&lt;/li&gt;   &lt;/ol&gt;    &lt;li&gt;Save the .proj file&lt;/li&gt;    &lt;li&gt;Open it back up in VS (or reload)&lt;/li&gt;    &lt;li&gt;Verify the correct version is not being used by viewing the properties of the dll in VS&lt;/li&gt;    &lt;li&gt;Get back to testing&lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;As you can see this is fixable, but it is also a bit of a hack/work around.&amp;#160; However this little bit of pain is worth the gains of adding tests to your code.&amp;#160; Now if only silverlight as a framework was more testable &lt;img style="border-bottom-style:none;border-right-style:none;border-top-style:none;border-left-style:none;" class="wlEmoticon wlEmoticon-sadsmile" alt="Sad smile" src="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/derik_5F00_whittaker/wlEmoticon_2D00_sadsmile_5F00_0D457A4A.png" /&gt;&lt;/p&gt;  &lt;p&gt;Till next time,&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devlicio.us/aggbug.aspx?PostID=68139" width="1" height="1"&gt;</description><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/TDD/default.aspx">TDD</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/Visual+Studio+2010/default.aspx">Visual Studio 2010</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/Silverlight/default.aspx">Silverlight</category></item><item><title>Testing that EventHandlers were wired up correctly with NUnit and Rhino Mocks</title><link>http://devlicio.us/blogs/derik_whittaker/archive/2010/08/24/testing-that-eventhandlers-were-wired-up-correctly-with-nunit-and-rhino-mocks.aspx</link><pubDate>Tue, 24 Aug 2010 11:04:04 GMT</pubDate><guid isPermaLink="false">40756a8b-6212-4073-9d98-6c26781577de:61665</guid><dc:creator>Derik Whittaker</dc:creator><slash:comments>2</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://devlicio.us/blogs/derik_whittaker/rsscomments.aspx?PostID=61665</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://devlicio.us/blogs/derik_whittaker/commentapi.aspx?PostID=61665</wfw:comment><comments>http://devlicio.us/blogs/derik_whittaker/archive/2010/08/24/testing-that-eventhandlers-were-wired-up-correctly-with-nunit-and-rhino-mocks.aspx#comments</comments><description>&lt;p&gt;Today I was trying to wrap some code in some tests (I got lazy and did not create the tests first… shot me).&amp;#160; What I was trying to ensure was that my event handlers I passed into a method were actually being wired up for usage.&amp;#160; Now I searched around the net for a while to see if there was a elegant solution to this problem but I could not find one.&amp;#160; Below is the solution I came up with.&amp;#160; Mind you this may not be a great solution, hell it may just down right suck but it works for me.&lt;/p&gt;  &lt;p&gt;First things first, her is the method i was trying to provide coverage for&lt;/p&gt;  &lt;pre class="c-sharp" name="code"&gt;public void GetAppointments( DateTime? from, DateTime? to, 
    EventHandler localRequestStarted,
    EventHandler remoteRequestStarted,
    EventHandler&lt;object&gt;&amp;gt; requestFinsished )
{
    var currentUser = _sessionManager.GetValue();
    var dataRequest = new AppointmentDataRequest( new AppointmentParameterContext( currentUser.ResourceIds, from.Value, to.Value ) );

    dataRequest.LocalRequestStarted += localRequestStarted;
    dataRequest.RemoteRequestStarted += remoteRequestStarted;
    dataRequest.RequestFinished += requestFinsished;

    _dataManager.Fetch( dataRequest );
}
&lt;/pre&gt;

&lt;p&gt;As you can see there are 3 lines in the above code where the passed in EventHandlers are being attached.&amp;#160; I wanted to ensure this. But what you may also see is that I have no direct access to the dataRequest object which is being created in this method.&amp;#160; That is where our handy rhino mocks library comes in.&amp;#160; With Rhino Mocks I am able to get the pointer to the various values which are passed into methods.&amp;#160; Check out the test below and you will see how this is done.&lt;/p&gt;

&lt;p&gt;My unit test&lt;/p&gt;

&lt;pre class="c-sharp" name="code"&gt;[Test]
public void GetAppointments_WhenCalled_EnsureWillWireupEventsCorrectly()
{
    var dataManager = MockRepository.GenerateMock&amp;lt;IDataManager&amp;gt;();
    var sessionManager = MockRepository.GenerateMock&amp;lt;ISessionManager&amp;gt;();

    var currentUser = new CurrentUser();
    sessionManager.Stub( x =&amp;gt; x.GetValue&amp;lt;CurrentUser&amp;gt;() ).Return( currentUser );

    var provider = new AppointmentProvider( dataManager, null, sessionManager, null );
    bool localWired = false, remoteWired = false, requestFinishedWired = false;

    EventHandler&amp;lt;LocalRequestStartedEventArgs&amp;gt; localRequest = ( s, arg ) =&amp;gt; { localWired = true; };
    EventHandler&amp;lt;RemoteRequestStartedEventArgs&amp;gt; remoteRequest = ( s, arg ) =&amp;gt; { remoteWired = true; };
    EventHandler&amp;lt;RequestFinishedEventArgs&amp;lt;object&amp;gt;&amp;gt; requestFinished = ( s, arg ) =&amp;gt; { requestFinishedWired = true; };

    provider.GetAppointments( DateTime.Now, DateTime.Now, localRequest, remoteRequest, requestFinished );

    IList&amp;lt;object[]&amp;gt; argumentsForCallsMadeOn = dataManager.GetArgumentsForCallsMadeOn( x =&amp;gt; x.Fetch( Arg&amp;lt;DataRequest&amp;gt;.Is.Anything ) );

    var dataRequest = (AppointmentDataRequest)argumentsForCallsMadeOn[ 0 ][ 0 ];

    dataRequest.RaiseLocalRequestStarted();
    dataRequest.RaiseRemoteRequestStarted();
    dataRequest.RaiseDataRequestFinished( DataRequestType.UserLogin, DataRequestResult.Unknown, null, null );

    Assert.That( localWired, Is.True );
    Assert.That( remoteWired, Is.True );
    Assert.That( requestFinishedWired, Is.True );

}&lt;/pre&gt;

&lt;p&gt;As you can see this test has a lot going on, but let me explain some of this for you.&lt;/p&gt;

&lt;p&gt;1) First thing we need to do is create a few local variables which will hold the state of the event firing&lt;/p&gt;

&lt;p&gt;2) Next we want to create local copies of our event delegates in order to push them into our method&lt;/p&gt;

&lt;p&gt;3) Next is time for the Rhino Mock magic.&amp;#160; Notice how I am calling the GetargumentsForCallsMadeOn() method.&amp;#160; This is a method in Rhino Mocks which allows me to reach into the call stack and pull out the values which were pushed into a method when it was called.&amp;#160; I then cast the argument i want to its native type.&lt;/p&gt;

&lt;p&gt;4) In order to ensure the events were wired up I need to call the various ‘raise’ methods in order to trigger them.&amp;#160; Doing this should cause my local state holders for the events to be changed and this is what we actually want to ensure&lt;/p&gt;

&lt;p&gt;5) Ensure the event state variables were set to true.&lt;/p&gt;

&lt;p&gt;There you have it, a simple (well kinda) way to ensure that your events have been registered correctly in your code.&lt;/p&gt;

&lt;p&gt;Till next time,&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;/object&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devlicio.us/aggbug.aspx?PostID=61665" width="1" height="1"&gt;</description><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/Agile/default.aspx">Agile</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/.Net/default.aspx">.Net</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/TDD/default.aspx">TDD</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/Rhino+Mocks/default.aspx">Rhino Mocks</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/HowTo/default.aspx">HowTo</category></item><item><title>Testing only the code of value</title><link>http://devlicio.us/blogs/derik_whittaker/archive/2009/10/07/testing-only-the-code-of-value.aspx</link><pubDate>Wed, 07 Oct 2009 11:48:25 GMT</pubDate><guid isPermaLink="false">40756a8b-6212-4073-9d98-6c26781577de:52340</guid><dc:creator>Derik Whittaker</dc:creator><slash:comments>13</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://devlicio.us/blogs/derik_whittaker/rsscomments.aspx?PostID=52340</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://devlicio.us/blogs/derik_whittaker/commentapi.aspx?PostID=52340</wfw:comment><comments>http://devlicio.us/blogs/derik_whittaker/archive/2009/10/07/testing-only-the-code-of-value.aspx#comments</comments><description>&lt;p&gt;I am 99% sure I have had a post like this in the past, but my google-foo was weak today and I could not find it.&amp;#160; Do not let anyone blow smoke up your back side, testing is expensive, testing takes time but most importantly testing &lt;em&gt;can&lt;/em&gt; help improve the quality of your code.&lt;/p&gt;  &lt;p&gt;If you are going to spend the time and money to create automated, rerun-able unit tests make sure you spend your time/money wisely.&amp;#160; Make sure you test the code that matters, test the code which is complicated (keep in mind a LOC count does NOT equal complexity).&lt;/p&gt;  &lt;p&gt;Today when scanning some code in another part of our project I came across this tests:&lt;/p&gt;  &lt;pre class="c-sharp" name="code"&gt;public void AdminSetIDTest()
{
	var target = new CreateTaskActivity();
	int expected = 50;
	int actual;
	target.AdminSetID = expected;
	actual = target.AdminSetID;
	Assert.AreEqual(expected, actual);
}&lt;/pre&gt;

&lt;p&gt;When I looked at this tests 2 bells immediately went off in my mind&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;The name of this tests SUCKS BALLS and does not clearly convey the intent of the test&lt;/li&gt;

  &lt;li&gt;This is testing that a property getter works (no, there is NO logic behind the getter/setter)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;If you disregard #1 from above for now (but remember clear/concise names do matter) and focus on #2 this tests adds no value to the test suite.&amp;#160; All this test is doing is ensuring that the .Net framework does its job.&amp;#160; This test is a total waste of time and energy and can actually cost you more time/money in the long run because you may have to change the useless test over time as you refactor.&lt;/p&gt;

&lt;p&gt;The key take away from this is simple.&amp;#160; You always have limited time and money when trying to get a product out the door.&amp;#160; Unit testing IMO can always help you to create a better product, but make sure you use your time and money in a way in which will allow you to maximize your ROI.&lt;/p&gt;

&lt;p&gt;Till next time,&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devlicio.us/aggbug.aspx?PostID=52340" width="1" height="1"&gt;</description><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/Agile/default.aspx">Agile</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/TDD/default.aspx">TDD</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/Opinion/default.aspx">Opinion</category></item><item><title>Your unit test may smell if…….!</title><link>http://devlicio.us/blogs/derik_whittaker/archive/2009/09/09/your-unit-test-may-smell-if.aspx</link><pubDate>Wed, 09 Sep 2009 17:28:30 GMT</pubDate><guid isPermaLink="false">40756a8b-6212-4073-9d98-6c26781577de:51179</guid><dc:creator>Derik Whittaker</dc:creator><slash:comments>8</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://devlicio.us/blogs/derik_whittaker/rsscomments.aspx?PostID=51179</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://devlicio.us/blogs/derik_whittaker/commentapi.aspx?PostID=51179</wfw:comment><comments>http://devlicio.us/blogs/derik_whittaker/archive/2009/09/09/your-unit-test-may-smell-if.aspx#comments</comments><description>&lt;p&gt;If you find yourself using reflection in your unit test to push &amp;#39;stub’ data into it your test just may smell.&amp;#160; Now there are times (especially when dealing with legacy code) that you need use reflection to crack open a class to push/pull values but I would strongly suggest you consider the solutions I am going to suggest.&lt;/p&gt;  &lt;p&gt;Utilizing the wrap method (see &lt;a href="http://www.amazon.com/Working-Effectively-Legacy-Michael-Feathers/dp/0131177052"&gt;Working with Legacy Code&lt;/a&gt;) to accomplish your goal.&amp;#160; &lt;/p&gt;  &lt;p&gt;Lets assume you have the following class which you want to test:&lt;/p&gt;  &lt;pre class="c#" name="code"&gt;  public class SomeClass 
  {
    private DateTime _lastVerified;
    private DateTime _lastActivated;
   }&lt;/pre&gt;

&lt;p&gt;Now one way to push data into these fields would be to do the following:&lt;/p&gt;

&lt;pre class="c#" name="code"&gt;    [Test]
    public void IsTimeToActivateTrueLastActivatedTheDayBeforeCurrentTimeAfterActivationTimeTest()
    {
      SomeClass accessor = new SomeClass 

      Type type = SomeClass 

      FieldInfo field2 = type.GetField(&amp;quot;_lastActivated&amp;quot;, BindingFlags.Instance | BindingFlags.NonPublic);
      field2.SetValue(accessor, new DateTime(2008, 2, 29, 10, 5, 0));

      FieldInfo field3 = type.GetField(&amp;quot;_lastVerified&amp;quot;, BindingFlags.Instance | BindingFlags.NonPublic);
      field3.SetValue(accessor, new DateTime(2008, 3, 1, 10, 0, 0));
    
      DateTime currentDateTime = new DateTime(2008, 3, 1, 10, 10, 0);

      MethodInfo method = type.GetMethod(&amp;quot;SomeMethod&amp;quot;, BindingFlags.Instance | BindingFlags.NonPublic);
      object result = method.Invoke(accessor, new object[1] { currentDateTime });

      bool isTime = (bool)result;

      Assert.AreEqual(true, isTime);
      Assert.AreEqual(currentDateTime, field3.GetValue(accessor));
    }&lt;/pre&gt;

&lt;p&gt;Now this works, but if you do this over and over again you will kill yourself with reflection code.&lt;/p&gt;

&lt;p&gt;Option 1) Create a subclass of your class and hide the reflection inside your subclass&lt;/p&gt;

&lt;pre class="c#" name="code"&gt;public class MySubclassOfSomeClass : SomeClass
  {
    public void SetLastActivatedTime( DateTime value )
    {
    	// set the value via reflection here
    {
	
    public void SetLastVerifiedTime( DateTime value )
    {
    	// set the value via reflection here
    {
   }&lt;/pre&gt;

&lt;p&gt;The code above will still use reflection to set the value, but it will hide the usage of reflection from your unit test and will present a less noisy test to future developers&lt;/p&gt;

&lt;p&gt;Option 2) Change the scope of the fields and subclass and extend&lt;/p&gt;

&lt;pre class="c#" name="code"&gt;  public class SomeClass 
  {
    protected DateTime _lastVerified;
    protected DateTime _lastActivated;
   }

public class MySubclassOfSomeClass : SomeClass
  {
    public void SetLastActivatedTime( DateTime value )
    {
    	_lastActivated = value;
    {
	
    public void SetLastVerifiedTime( DateTime value )
    {
    	_lastVerified = value;
    {
   &lt;/pre&gt;

&lt;p&gt;If you change the scope of the fields to protected you could subclass the original class and do the same as option 1, but because you have access to the fields via inheritance there is no need to use reflection.&lt;/p&gt;

&lt;p&gt;So, remember that tests are code to and if you feel pain writing test you may be doing it wrong.&lt;/p&gt;

&lt;p&gt;Till next time,&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devlicio.us/aggbug.aspx?PostID=51179" width="1" height="1"&gt;</description><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/Agile/default.aspx">Agile</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/TDD/default.aspx">TDD</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/Opinion/default.aspx">Opinion</category></item><item><title>You know you buy into Testing and Testabilty when you wrap a singleton simply to create an abstraction…</title><link>http://devlicio.us/blogs/derik_whittaker/archive/2009/05/15/you-know-you-buy-into-testing-and-testabilty-when-you-wrap-a-singleton-simply-to-create-an-abstraction.aspx</link><pubDate>Fri, 15 May 2009 22:27:58 GMT</pubDate><guid isPermaLink="false">40756a8b-6212-4073-9d98-6c26781577de:46845</guid><dc:creator>Derik Whittaker</dc:creator><slash:comments>2</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://devlicio.us/blogs/derik_whittaker/rsscomments.aspx?PostID=46845</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://devlicio.us/blogs/derik_whittaker/commentapi.aspx?PostID=46845</wfw:comment><comments>http://devlicio.us/blogs/derik_whittaker/archive/2009/05/15/you-know-you-buy-into-testing-and-testabilty-when-you-wrap-a-singleton-simply-to-create-an-abstraction.aspx#comments</comments><description>&lt;p&gt;I am a little bored so I thought I would write a nice fluent interface around the Performance Counter crap that is part of .net.&amp;#160; I know, I know the world does not really need another Fluent Interface around something, but I am bored and this is keeping be busy while waiting for my flight.&lt;/p&gt;  &lt;p&gt;Anyway, about 30 min into the coding session (going a bit slow as I am trying to use CodeRush/Refactor Pro in place of ReSharper) I needed to use the PerformanceCounterCategory class.&amp;#160; The problem is this.&amp;#160; Since this is a singleton isolating this during my tests is too painful, and because it is a singleton I cannot create an inheritance hierarchy to allow me to isolate it better.&amp;#160; So, what did I do?&amp;#160; &lt;/p&gt;  &lt;p&gt;I created a wrapper around the singleton.&amp;#160; By having this wrapper (and accompanying interface) I will be able to better isolate my tests and not actually create a shit load of categories and counters all the time.&lt;/p&gt;  &lt;p&gt;Wrap Strategy Refactoring === FOR THE WIN&lt;/p&gt;  &lt;p&gt;Singletons == FOR THE LOSS&lt;/p&gt;  &lt;p&gt;Till next time,&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devlicio.us/aggbug.aspx?PostID=46845" width="1" height="1"&gt;</description><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/TDD/default.aspx">TDD</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/Opinion/default.aspx">Opinion</category></item><item><title>Teaching someone to test using an Isolation Framework</title><link>http://devlicio.us/blogs/derik_whittaker/archive/2008/12/30/teaching-someone-to-test-using-an-isolation-framework.aspx</link><pubDate>Tue, 30 Dec 2008 17:21:12 GMT</pubDate><guid isPermaLink="false">40756a8b-6212-4073-9d98-6c26781577de:43560</guid><dc:creator>Derik Whittaker</dc:creator><slash:comments>14</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://devlicio.us/blogs/derik_whittaker/rsscomments.aspx?PostID=43560</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://devlicio.us/blogs/derik_whittaker/commentapi.aspx?PostID=43560</wfw:comment><comments>http://devlicio.us/blogs/derik_whittaker/archive/2008/12/30/teaching-someone-to-test-using-an-isolation-framework.aspx#comments</comments><description>&lt;p&gt;Part of my job at work is to teach and mentor other developers on our team.&amp;nbsp; Right now I am in the process of teaching two of our developers how to create unit tests (notice I did NOT say integration tests because most anyone can do those).&amp;nbsp; We are also learning how to create our tests by utilizing an Isolation Framework (aka mocking framework).&lt;/p&gt; &lt;p&gt;I am really excited for this opportunity because I firmly believe that you create better software when you do it by creating tests to prove your code works.&amp;nbsp; I am also excited because both of the developer buy into the idea of testing and are extremely eager to learn how to to better test their code.&lt;/p&gt; &lt;p&gt;Because we had a few days of downtime because of the Christmas holiday before our 1st sprint on our project we thought it would be a good time to do some pairing (guess it would be better called tri-pairing).&amp;nbsp; Our plan of attack was to start to flush out some of the features in our system but do it in a total TDD manor.&amp;nbsp; We were also going to be utilizing the Rhino Mock Isolation framework in our tests.&lt;/p&gt; &lt;p&gt;So over the next 2 days we spent about 12 hours or so working building out our code.&amp;nbsp; Over this time we actually were able to create an complete end to end &amp;#39;version&amp;#39; (I say version because we did not fill in all the functionality of the code but were able to get all the major pieces stubbed out) which allowed us to flush out many, many more business requirement and build a simple, yet flexible code base.&lt;/p&gt; &lt;p&gt;I hope both of my co-workers learned a ton from this exercise, I know I did.&amp;nbsp; This was the first time where I had actually spent any significant amount of time teaching someone who was new to testing how to do so.&amp;nbsp; Sure I had spent an hour here or an hour there, but nothing like this.&amp;nbsp; &lt;/p&gt; &lt;p&gt;What I really wanted to share with everyone is what I learned form this experience.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Slowdown, slowdown, slowdown&lt;br /&gt;&lt;/strong&gt;The first thing you should do when teaching something how to do anything is SLOWDOWN.&amp;nbsp; You have to remember that if you are talking/teaching to someone who is new to this they have to not only try to process the information so they can understand it, they also have to try to remember it.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Make NO assumptions, teach as if they know nothing&lt;br /&gt;&lt;/strong&gt;This one was the most important thing I learned.&amp;nbsp; You cannot make assumptions on anything.&amp;nbsp; Anytime you say anything make sure you fully explain it.&amp;nbsp; If you use an acronym EXPLAIN IT.&amp;nbsp; Any time you mention a buzz word EXPLAIN IT.&amp;nbsp; Plan and simple EXPLAIN EVERYTHING&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Have them drive&lt;br /&gt;&lt;/strong&gt;During the teaching part it is critical that you have then code, have them tell you what to do.&amp;nbsp; It is ok for you to &amp;#39;lead&amp;#39; them in the right direction, but you must not always drive.&amp;nbsp; This will really help to drive home the concepts.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Provide examples both with and without the Isolation framework&lt;br /&gt;&lt;/strong&gt;In our case because I was trying to teach them testing using an Isolation framework it really helped when I would create a test (aka integration) with no mocks and then re-create it with mocks.&amp;nbsp; Doing this really helped to explain to them how using the Isolation framework removed dependencies.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Don&amp;#39;t let them skate by&lt;br /&gt;&lt;/strong&gt;Don&amp;#39;t let them simply nod their head as if they understand.&amp;nbsp; Make sure you keep asking them if there is anything you can clear up or explain better.&amp;nbsp; At first they are going to simply say no, they are good.&amp;nbsp; But as you keep asking and start having them drive they WILL start to ask more questions, I promise.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Turn off any coding tools such as ReSharper (or the likes) and do NOT use shortcuts&lt;br /&gt;&lt;/strong&gt;This may have been the biggest issue for us at first.&amp;nbsp; I am pretty good with ReSharper (if I can toot my own horn here) and I was coding with it as I would do if I were by myself.&amp;nbsp; On more than one occasion the would look at me cross-eyed and ask &amp;#39;what the hell just happened&amp;#39;.&amp;nbsp; Finally I simply stopped using it for the first day.&amp;nbsp; On the second day I went back to using R#, but I turned on &lt;a href="http://weblogs.asp.net/rosherove/archive/2007/06/03/train-to-be-a-keyboard-master-with-keyboard-jedi.aspx"&gt;Keyboard Jedi&lt;/a&gt; so they could see what was going on.&amp;nbsp; Even though I turned on Keyboard Jedi, I tried my best to make sure to explain what just happened when used R#.&lt;/p&gt; &lt;p&gt;Anyway, I have rambled on long enough and I think I have pretty much gotten my thoughts out there.&amp;nbsp; I really enjoyed working with these guys and I am looking forward to doing so again when we get back from break.&lt;/p&gt; &lt;p&gt;Hope this helps, &lt;/p&gt; &lt;p&gt;Till next time,&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devlicio.us/aggbug.aspx?PostID=43560" width="1" height="1"&gt;</description><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/Agile/default.aspx">Agile</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/TDD/default.aspx">TDD</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/Rhino+Mocks/default.aspx">Rhino Mocks</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/Opinion/default.aspx">Opinion</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/HowTo/default.aspx">HowTo</category></item><item><title>Testing is hard but debugging just sucks A$$</title><link>http://devlicio.us/blogs/derik_whittaker/archive/2008/11/14/testing-is-hard-but-debugging-just-sucks-a.aspx</link><pubDate>Fri, 14 Nov 2008 23:58:05 GMT</pubDate><guid isPermaLink="false">40756a8b-6212-4073-9d98-6c26781577de:43064</guid><dc:creator>Derik Whittaker</dc:creator><slash:comments>23</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://devlicio.us/blogs/derik_whittaker/rsscomments.aspx?PostID=43064</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://devlicio.us/blogs/derik_whittaker/commentapi.aspx?PostID=43064</wfw:comment><comments>http://devlicio.us/blogs/derik_whittaker/archive/2008/11/14/testing-is-hard-but-debugging-just-sucks-a.aspx#comments</comments><description>&lt;p&gt;In my last post (&lt;a href="http://feeds.feedburner.com/~r/Devlicious/~3/451762368/talking-mocks-at-trinug-what-a-great-time-what-a-great-group.aspx"&gt;here&lt;/a&gt;) I was giving a wrap up of&amp;nbsp;the Mocking session I recently did at &lt;a href="http://www.trinug.org"&gt;TriNug&lt;/a&gt;.&amp;nbsp; In that post I gave some of the reasons (sorry, I meant excuses) people gave for not doing any type of automated testing during their dally development ritual (notice I am staying away from TDD at this point).&amp;nbsp; I thought that those topics would be better suited to be broken out into their own post.&lt;/p&gt; &lt;p&gt;At the users group I asked the question to the group &amp;#39;who creates automated tests as part of their daily development cycle?&amp;#39;.&amp;nbsp; After I asked this question I followed it up with, and if you don&amp;#39;t WHY, WHY, WHY, WHY......&amp;nbsp; Below are some of the answers I received (btw, not the first time I have heard these reasons).&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Reason #1 - It is too hard to get started:&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Point:&lt;/strong&gt; This statement is nothing new, I hear this all the time.&amp;nbsp; To be honest I agree with them, testing is hard.&amp;nbsp; It takes time and effort to learn how to do it.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Counter Point: &lt;/strong&gt;But if you think learning to write tests and learning how to create testable code is hard, then what do you do when you need to learn a new product?&amp;nbsp; I can break it down like this.&amp;nbsp; Testing == Coding and Coding == REAL FREAKING HARD.&amp;nbsp; Stop using &amp;#39;testing is hard&amp;#39; as a crutch and just give it a shot.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Reason #2&amp;nbsp;- My client/company is not paying me to write tests:&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Point: &lt;/strong&gt;This one always make me laugh.&amp;nbsp; Since testing does take time (not going to sugar coat this at all), and can slow down your pace of development, many people feel that they are not being paid to create tests.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Counter Point:&amp;nbsp; &lt;/strong&gt;This one is real simple, ask your self these two questions.&amp;nbsp; &lt;/p&gt; &lt;ol&gt; &lt;li&gt;Am I being paid to produce quality or crap?&amp;nbsp; &lt;/li&gt; &lt;li&gt;Am I being paid to debug?&amp;nbsp; &lt;/li&gt;&lt;/ol&gt; &lt;p&gt;I am going to assume that both of those answers are NO, and if they are not then I would suggest you stop reading this post as it does not get any better from here.&amp;nbsp; &lt;br /&gt;&lt;br /&gt;Now that we are on the same page and we understand you are being paid to produce quality code why would you not want to do everything you can to bake that&amp;nbsp;quality into your code up front?&amp;nbsp; This can happen with tests.&amp;nbsp; Take the time, take the challenge and create some tests.&amp;nbsp; Trust me, no one ever got fired for being a bit late with an application that was freaking solid from a quality standpoint (and if you do get fired because of it just look at it this way, you have a new&amp;nbsp;and marketable skill to help you find your new job).&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Reason #3 - I do not have time&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Point: &lt;/strong&gt;Testing takes time, and when time is short people throw every &amp;#39;non-critical&amp;#39; functions out the window.&amp;nbsp; And sadly people think that quality is a non-critical function.&amp;nbsp; To prove this point just take a look at 90% of the applications out there... they suck ASS&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Counter Point:&amp;nbsp; &lt;/strong&gt;Just ask yourself this question.&amp;nbsp; Would I rather spend what little time I have creating tests to help ensure I have quality or would I rather spend time later stepping through code via the debugger looking for the bug I could have caught/fixed earlier?&amp;nbsp; If you would rather spend time in the debugger, then more power to you.&lt;br /&gt;&lt;br /&gt;NOTE: Do NOT take the above statement as me saying that testers NEVER debug, they do but just a TON less than others.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Reason #4 - My code will not allow me to tests&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Point:&lt;/strong&gt;&amp;nbsp; This is one may be the only excuse that has some merit.&amp;nbsp; Poor code is hard to test.&amp;nbsp; &lt;/p&gt; &lt;p&gt;&lt;strong&gt;Counter Point:&amp;nbsp; &lt;/strong&gt;Simply because you do not need to retrofit your entire code base at one time.&amp;nbsp; If you have &amp;#39;bad&amp;#39; code that is easy to test that is fine.&amp;nbsp; Start testing with NEW code.&amp;nbsp; Hopefully you will not be creating bad code once you understand your current code is not the best.&amp;nbsp; You will also come to understand that when you start testing your code will start to get a little cleaner.&amp;nbsp; Finally, if you really want to start to test your legacy code, go out and pick up &amp;#39;&lt;a href="http://www.amazon.com/Working-Effectively-Legacy-Robert-Martin/dp/0131177052"&gt;Working Effectively w/ Legacy Code&lt;/a&gt;&amp;#39; by Michael Feathers&lt;/p&gt; &lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;As you can tell from my tone, I do not buy into any of these reasons, sorry excuses.&amp;nbsp; I wish that when I ask people this question and they gave me a response they would simply state the truth.&amp;nbsp; And the truth is people do not test for the following 2 reasons&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Reason #1 - They do not believe that creating tests will improve their code&lt;br /&gt;&lt;/strong&gt;If this is what you really think, that is fine.&amp;nbsp; You are allowed to have your beliefs and I am allowed to have mine.&amp;nbsp; As long as we understand each other we can get along just fine.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Reason #2 - They are lazy&lt;br /&gt;&lt;/strong&gt;Not sure I need to explain this one.&lt;/p&gt; &lt;p&gt;Let the flames begin :)&lt;/p&gt; &lt;p&gt;Till next time,&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devlicio.us/aggbug.aspx?PostID=43064" width="1" height="1"&gt;</description><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/Agile/default.aspx">Agile</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/TDD/default.aspx">TDD</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/Opinion/default.aspx">Opinion</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/Rant/default.aspx">Rant</category></item><item><title>Talking Mocks at TriNug, what a great time, what a great group</title><link>http://devlicio.us/blogs/derik_whittaker/archive/2008/11/13/talking-mocks-at-trinug-what-a-great-time-what-a-great-group.aspx</link><pubDate>Thu, 13 Nov 2008 12:36:01 GMT</pubDate><guid isPermaLink="false">40756a8b-6212-4073-9d98-6c26781577de:43022</guid><dc:creator>Derik Whittaker</dc:creator><slash:comments>2</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://devlicio.us/blogs/derik_whittaker/rsscomments.aspx?PostID=43022</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://devlicio.us/blogs/derik_whittaker/commentapi.aspx?PostID=43022</wfw:comment><comments>http://devlicio.us/blogs/derik_whittaker/archive/2008/11/13/talking-mocks-at-trinug-what-a-great-time-what-a-great-group.aspx#comments</comments><description>&lt;p&gt;Last night I had the opportunity to&amp;nbsp;do my &amp;#39;Taking your tests to the next level with Mocks&amp;#39;&amp;nbsp;session&amp;nbsp;to the &lt;a href="http://trinug.org/"&gt;TriNug&lt;/a&gt; user group.&amp;nbsp; I would first like to say thanks to Doug Wilson and his entire group.&amp;nbsp; They had a great turn out (45ish people) and they asked a ton of great questions.&lt;/p&gt; &lt;p&gt;To kick off the session I ask the same question I ask everything I give this session &amp;#39;Who in here writes tests as part of their development routine?&amp;#39;.&amp;nbsp; The response I got did not surprise me, about 30% said they did.&amp;nbsp; I then asked those 30%, who using a mocking framework?&amp;nbsp; Again the response did not surprise me, only about 50%.&lt;/p&gt; &lt;p&gt;Of course with only 30% even saying they test, I had to ask why, why and why.&amp;nbsp; The responses I got I have heard before and thought I would share them&lt;/p&gt; &lt;ul&gt; &lt;li&gt;&lt;strong&gt;It is too hard to get started&lt;br /&gt;&lt;/strong&gt;I have heard this one before, and I am not going to lie to you, writing tests is hard, it takes effort and time to learn how to do it.&amp;nbsp; But just ask yourself this.&amp;nbsp; When learning anything new is it easy?&amp;nbsp; Are you able to just pickup a new tool/technology and &amp;#39;know it&amp;#39; or do you have to learn it?&amp;nbsp; My guess you have to learn it, testing/mocking is no different.&lt;br /&gt;&lt;/li&gt; &lt;li&gt;&lt;strong&gt;My client/company is not paying me to write tests&lt;br /&gt;&lt;/strong&gt;Sorry, but this is one statement have to call BS on.&amp;nbsp; I immediately asked, is your company paying you to write shitty quality?&amp;nbsp; Or are they paying you to produce quality code?&amp;nbsp; If they are paying you to write shitty code, &lt;font color="#ff0000"&gt;STOP&lt;/font&gt; reading now as I am done talking to you (ok, may be not, but really??? shitty code is what they want???).&amp;nbsp; If they are paying you to create quality code how can you insure it without tests?&amp;nbsp; My guess is that you have tests, but they just happen to be of the manual, error prone nature.&lt;br /&gt;&lt;/li&gt; &lt;li&gt;&lt;strong&gt;I do not have time&lt;br /&gt;&lt;/strong&gt;Again, another one I call BS on.&amp;nbsp; I followed this up with &amp;#39;let me guess, you have time to debug/bug hunt at the end right?&amp;#39;.&amp;nbsp; The key to testing is that it does take time (wow, that is honest) but it is either a pay me now, or pay me later scenario.&amp;nbsp; Either you take the time now to embed quality or you take the time later to duck-tap quality.&amp;nbsp; Your choice?&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;With this information in hand, I really attempted to drive home the values of both testing as well as using a mocking framework to remove dependencies.&amp;nbsp; I think towards the end of the night I had converted some people to &amp;#39;believers&amp;#39; and hopefully they will either give testing a solid go (assuming they are not testing right now) or give using a mocking framework a go.&lt;/p&gt; &lt;p&gt;You can get any of my session information from Google code&amp;nbsp;from this location&amp;nbsp;&lt;a title="http://code.google.com/p/graudo/" href="http://code.google.com/p/graudo/"&gt;http://code.google.com/p/graudo/&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;Till next time,&lt;/p&gt; &lt;p&gt;&lt;font color="#808080"&gt;&lt;strong&gt;[----- Remember to check out &lt;/strong&gt;&lt;strong&gt;&lt;a href="http://www.dimecasts.net"&gt;DimeCasts.Net&lt;/a&gt;&lt;/strong&gt;&lt;strong&gt; -----]&lt;/strong&gt;&lt;/font&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devlicio.us/aggbug.aspx?PostID=43022" width="1" height="1"&gt;</description><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/Development/default.aspx">Development</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/TDD/default.aspx">TDD</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/Rhino+Mocks/default.aspx">Rhino Mocks</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/Presentations/default.aspx">Presentations</category></item><item><title>Using the RhinoAutoMocker that is part of StructureMap 2.5</title><link>http://devlicio.us/blogs/derik_whittaker/archive/2008/10/05/using-the-rhinoautomocker-that-is-part-of-structuremap-2-5.aspx</link><pubDate>Sun, 05 Oct 2008 18:58:25 GMT</pubDate><guid isPermaLink="false">40756a8b-6212-4073-9d98-6c26781577de:42580</guid><dc:creator>Derik Whittaker</dc:creator><slash:comments>10</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://devlicio.us/blogs/derik_whittaker/rsscomments.aspx?PostID=42580</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://devlicio.us/blogs/derik_whittaker/commentapi.aspx?PostID=42580</wfw:comment><comments>http://devlicio.us/blogs/derik_whittaker/archive/2008/10/05/using-the-rhinoautomocker-that-is-part-of-structuremap-2-5.aspx#comments</comments><description>&lt;p&gt;One of the new features that is part of the next release of &lt;a href="http://structuremap.sourceforge.net/"&gt;StructureMap&lt;/a&gt; 2.5 is a AutoMocking Container.&amp;nbsp; &lt;/p&gt; &lt;p&gt;What is an AutoMocking Container, well per Jacob over at Eleutian an AutoMocker is&lt;/p&gt; &lt;blockquote&gt; &lt;p&gt;AutoMockingContainer is simply a IoCContainer with a custom facility and dependency resolver that supplies a Mock (RhinoMock) for any interface that is resolved.&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;My definition is a little more straight forward and uses simpler word (remember I am a simpleton :))&lt;/p&gt; &lt;blockquote&gt; &lt;p&gt;An AutoMocking container is simply a tool that will inject mock dependencies into your object for you.&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;What I want to do today is show how an AutoMocking Container can reduce the amount of code/noise from your tests.&amp;nbsp;&amp;nbsp; I am going to first show a tests that simply uses RhinoMocks then that same test that uses the RhinoAutoMocker&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Test with only RhinoMocks&lt;/strong&gt;&lt;/p&gt;&lt;pre class="c-sharp" name="code"&gt;[Test]
public void NoAutoMocker()
{
	var mockProvider = MockRepository.GenerateMock&amp;lt;IPersistingRulesProvider&amp;gt;();
        var mockRepository = MockRepository.GenerateMock&amp;lt;ISynchronizationRepository&amp;gt;();
        var mockPersistanceProvider = MockRepository.GenerateMock&amp;lt;IPersistanceProvider&amp;gt;();
        var mockLogger = MockRepository.GenerateMock&amp;lt;ILogger&amp;gt;();

	// Expectations
        mockProvider.Expect(x =&amp;gt; x.ExecuteRules(null)).IgnoreArguments().Throw(new Exception(&amp;quot;Do not care what this is&amp;quot;));
        mockRepository.Expect(x =&amp;gt; x.StartTransaction()).Repeat.Once();
        mockRepository.Expect(x =&amp;gt; x.RollbackTransaction()).Repeat.Once();
        mockRepository.Expect( x =&amp;gt; x.CommitTransaction() ).Repeat.Never();

	var persitingPipeline = new PersistingPipeline(mockProvider, mockPersistanceProvider, mockRepository, mockLogger);
        var result = persitingPipeline.PersistChanges(new DataSet(), 0, 0, 0);

	Assert.That( result, Is.Not.Empty );

	mockRepository.VerifyAllExpectations();
}

&lt;/pre&gt;
&lt;p&gt;This code above has a bit of noise.&amp;nbsp; Because my object has a dependency on 4 other objects i need to create mocks for each of these.&amp;nbsp; This creates more work and just adds to the test noise. 
&lt;p&gt;&lt;strong&gt;Test with the RhinoAutoMocker&lt;/strong&gt;&lt;/p&gt;&lt;pre class="c-sharp" name="code"&gt;[Test]
public void WithAutoMocker()
{
	var mockPipeline = new RhinoAutoMocker&amp;lt;PersistingPipeline&amp;gt;();

	mockPipeline.Get&amp;lt;IPersistingRulesProvider&amp;gt;().Expect( x =&amp;gt; x.ExecuteRules( null ) ).IgnoreArguments().Throw( new Exception( &amp;quot;Do not care what this is&amp;quot; ) );
	mockPipeline.Get&amp;lt;ISynchronizationRepository&amp;gt;().Expect(x =&amp;gt; x.StartTransaction()).Repeat.Once();
        mockPipeline.Get&amp;lt;ISynchronizationRepository&amp;gt;().Expect(x =&amp;gt; x.RollbackTransaction()).Repeat.Once();
        mockPipeline.Get&amp;lt;ISynchronizationRepository&amp;gt;().Expect(x =&amp;gt; x.CommitTransaction()).Repeat.Never();

	var result = mockPipeline.ClassUnderTest.PersistChanges( new DataSet(), 0, 0, 0 );

	Assert.That( result, Is.Not.Empty );

}
&lt;/pre&gt;
&lt;p&gt;The code above does not require me to create mocks for each of my dependencies, the AutoMocker will do that for me.&lt;/p&gt;
&lt;p&gt;Also notice that when I need to set an expectation for a dependencies I can access it via the .Get&amp;lt;&amp;gt;() method.&amp;nbsp; &lt;/p&gt;
&lt;p&gt;Till next time,&lt;/p&gt;
&lt;p&gt;&lt;font color="#808080"&gt;&lt;strong&gt;[----- Remember to check out &lt;/strong&gt;&lt;strong&gt;&lt;a href="http://www.dimecasts.net"&gt;DimeCasts.Net&lt;/a&gt;&lt;/strong&gt;&lt;strong&gt; -----]&lt;/strong&gt;&lt;/font&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devlicio.us/aggbug.aspx?PostID=42580" width="1" height="1"&gt;</description><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/Development+Tools/default.aspx">Development Tools</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/Agile/default.aspx">Agile</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/TDD/default.aspx">TDD</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/StructureMap/default.aspx">StructureMap</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/Rhino+Mocks/default.aspx">Rhino Mocks</category></item><item><title>Clean build server with MSTest == FAIL</title><link>http://devlicio.us/blogs/derik_whittaker/archive/2008/09/25/clean-build-server-with-mstest-fail.aspx</link><pubDate>Thu, 25 Sep 2008 10:10:32 GMT</pubDate><guid isPermaLink="false">40756a8b-6212-4073-9d98-6c26781577de:42436</guid><dc:creator>Derik Whittaker</dc:creator><slash:comments>4</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://devlicio.us/blogs/derik_whittaker/rsscomments.aspx?PostID=42436</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://devlicio.us/blogs/derik_whittaker/commentapi.aspx?PostID=42436</wfw:comment><comments>http://devlicio.us/blogs/derik_whittaker/archive/2008/09/25/clean-build-server-with-mstest-fail.aspx#comments</comments><description>&lt;p&gt;&lt;/p&gt; &lt;p&gt;It is no secret that I am not a fan of MSTest (read &lt;a href="http://devlicio.us/blogs/derik_whittaker/archive/2008/07/23/mstest-why-i-hate-you-you-cause-me-too-much-friction.aspx" target="_blank"&gt;here&lt;/a&gt; for more rants on MSTests).&amp;nbsp; Today&amp;#39;s rant is about how MSTest does not allow you to have a clean build server.&lt;/p&gt; &lt;p&gt;&lt;em&gt;Yea I know what you are thinking, here comes another long winded rant on MSTest.&amp;nbsp; Well this should not be too long winded, and hey, it is my blog and I can rant if I want to :).&lt;/em&gt;&lt;/p&gt; &lt;p&gt;This week I was trying to setup our build server and I need it to run MSTest tests.&amp;nbsp; I know that MSTest does not run like NUnit, but thought for sure&amp;nbsp;there was a way I could get my tests to run without having to install the full blown version of Visual Studio.&amp;nbsp; After a bit of searching and asking others I came to final conclusion that in fact you cannot get MSTest to run without Visual Studio.&amp;nbsp; &lt;/p&gt; &lt;p&gt;This is an issue to me because when I setup my build server I like to keep it clean.&amp;nbsp; I do NOT want to install any 3rd party software.&amp;nbsp; The way I see it is like this.&amp;nbsp; If we are not going to install the software package on the end users computer, why should I need to install them on our build server, and the last time I checked we do not install Visual Studio on our end users computer.&lt;/p&gt; &lt;p&gt;This is another issue to me because MSTest is the ONLY test framework (for .Net) that I know of that does not run with a single DLL placed into the bin (or any other output directory).&amp;nbsp; I just have to ask the genius&amp;#39; over in Redmond what the hell were they smoking when they decided to build MSTest.&amp;nbsp; It is pretty clear they had no prior knowledge of how to use the other tools such as NUnit, MBUnit or xUnit (I know, xUnit was not out yet).&amp;nbsp; I know this because of all the various testing frameworks MSTest is the one that does everything different.&amp;nbsp; You could argue they were on the cutting edge and were innovating, but I call BS on that.&lt;/p&gt; &lt;p&gt;Anyway, I feel better now telling the world another reason why I am not a fan of MSTest.&amp;nbsp; Sadly I am stuck using it&amp;nbsp;for now and at least in the short term as we have hundred of tests already written in MSTest.&amp;nbsp; But rest assured that I am on a crusade to get our team to switch from MSTest to NUnit (or any other logical framework).&lt;/p&gt; &lt;p&gt;Till next time,&lt;/p&gt; &lt;p&gt;&lt;em&gt;&lt;font color="#808080"&gt;&lt;strong&gt;[----- Remember to check out &lt;/strong&gt;&lt;strong&gt;&lt;a href="http://www.dimecasts.net"&gt;DimeCasts.Net&lt;/a&gt;&lt;/strong&gt;&lt;strong&gt; -----]&lt;/strong&gt;&lt;/font&gt;&lt;/em&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devlicio.us/aggbug.aspx?PostID=42436" width="1" height="1"&gt;</description><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/TDD/default.aspx">TDD</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/Rant/default.aspx">Rant</category></item><item><title>Testing your IoC Bindings</title><link>http://devlicio.us/blogs/derik_whittaker/archive/2008/09/10/testing-your-ioc-bindings.aspx</link><pubDate>Wed, 10 Sep 2008 11:53:55 GMT</pubDate><guid isPermaLink="false">40756a8b-6212-4073-9d98-6c26781577de:42272</guid><dc:creator>Derik Whittaker</dc:creator><slash:comments>7</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://devlicio.us/blogs/derik_whittaker/rsscomments.aspx?PostID=42272</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://devlicio.us/blogs/derik_whittaker/commentapi.aspx?PostID=42272</wfw:comment><comments>http://devlicio.us/blogs/derik_whittaker/archive/2008/09/10/testing-your-ioc-bindings.aspx#comments</comments><description>&lt;p&gt;One thing I like to do when I am using a IoC (Inversion of Control) container is to create simple test that ensure that my objects have been wired up correctly and can be created via the IoC container.&amp;nbsp; &lt;/p&gt; &lt;p&gt;I know this may seem like overkill, but I feel that by having my IoC bindings covered by tests I am covering all my bases.&lt;/p&gt; &lt;p&gt;So, what does testing my bindings do for me&lt;/p&gt; &lt;ul&gt; &lt;li&gt;&lt;strong&gt;Allows me to know if my object is configured correctly&lt;/strong&gt;&lt;br /&gt;By having these tests I will know immediately if I have somehow broken my IoC bindings glue (yes, glue is the technical term in this case).&amp;nbsp; &lt;br /&gt;&lt;br /&gt;It is not hard to phantom that when making changes to your IoC bindings logic (either via config files or via inline code) you can mistakenly break something.&amp;nbsp; Having these tests provides me immediate feedback if this were to happen.&lt;br /&gt; &lt;li&gt;&lt;strong&gt;Allows me to know if my objects dependencies are configured correctly&lt;br /&gt;&lt;/strong&gt;Setting up the wiring for your main object is only half the battle.&amp;nbsp; When using an IoC container many time you are going to have that container do some sort of Constructor Injection of your dependencies.&amp;nbsp; &lt;br /&gt;&lt;br /&gt;By having tests that simply create my object with IoC I will find out immediately if one of my dependency objects is not wired up.&amp;nbsp; This scenario is pretty common and having this test can save you some headaches.&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;Here is the test code I use for my IoC bindings tests:&lt;/p&gt; &lt;p&gt;[Test]&lt;br /&gt;public void CanCreateViaDI()&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; var iocObject = ObjectFactory.GetInstance&amp;lt; YourObjectHere &amp;gt;(); &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Assert.That( iocObject, Is.Not.Null );  &lt;p&gt;} &lt;p&gt;Hope this helps someone. &lt;p&gt;Till next time, &lt;p&gt;&lt;font color="#808080"&gt;&lt;strong&gt;[----- Remember to check out &lt;/strong&gt;&lt;strong&gt;&lt;a href="http://www.dimecasts.net"&gt;DimeCasts.Net&lt;/a&gt;&lt;/strong&gt;&lt;strong&gt; -----]&lt;/strong&gt;&lt;/font&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devlicio.us/aggbug.aspx?PostID=42272" width="1" height="1"&gt;</description><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/Development/default.aspx">Development</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/TDD/default.aspx">TDD</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/Best+Practice/default.aspx">Best Practice</category></item><item><title>Is it evil to use reflection when testing?</title><link>http://devlicio.us/blogs/derik_whittaker/archive/2008/07/29/is-it-evil-to-use-reflection-when-testing.aspx</link><pubDate>Tue, 29 Jul 2008 11:55:29 GMT</pubDate><guid isPermaLink="false">40756a8b-6212-4073-9d98-6c26781577de:41529</guid><dc:creator>Derik Whittaker</dc:creator><slash:comments>19</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://devlicio.us/blogs/derik_whittaker/rsscomments.aspx?PostID=41529</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://devlicio.us/blogs/derik_whittaker/commentapi.aspx?PostID=41529</wfw:comment><comments>http://devlicio.us/blogs/derik_whittaker/archive/2008/07/29/is-it-evil-to-use-reflection-when-testing.aspx#comments</comments><description>&lt;p&gt;I have a scenario where I have a private method that needs to be tested and the only way I can get to that method is by calling another public method and exercising all of its logic.&amp;nbsp; &lt;/p&gt; &lt;p&gt;This private method has a few different pathways and I would like to create tests for each of them.&amp;nbsp; I could do this by creating tests for the public method and just ensure that each of the tests exercise the various pathways of the private, but that just seems like too much work and effort.&lt;/p&gt; &lt;p&gt;So, my question to you is this.&amp;nbsp; Is it evil to use reflection to test a private method?&lt;/p&gt; &lt;p&gt;BTW, I know I could make the method internal and use the [InternalsVisibleTo] trick, but I do not want to make this method internal?&lt;/p&gt; &lt;p&gt;Thoughts, opinions, feedback,&lt;/p&gt; &lt;p&gt;Till next time,&lt;/p&gt; &lt;p&gt;&lt;font color="#808080"&gt;&lt;strong&gt;[----- Remember to check out &lt;/strong&gt;&lt;strong&gt;&lt;a href="http://www.dimecasts.net"&gt;DimeCasts.Net&lt;/a&gt;&lt;/strong&gt;&lt;strong&gt; -----]&lt;/strong&gt;&lt;/font&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devlicio.us/aggbug.aspx?PostID=41529" width="1" height="1"&gt;</description><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/TDD/default.aspx">TDD</category></item><item><title>RhinoMocks new Arrange, Act, Assert does not seem to work under MSTest....odd</title><link>http://devlicio.us/blogs/derik_whittaker/archive/2008/07/23/rhinomocks-new-arrange-act-assert-does-not-seem-to-work-under-mstest-odd.aspx</link><pubDate>Wed, 23 Jul 2008 15:38:39 GMT</pubDate><guid isPermaLink="false">40756a8b-6212-4073-9d98-6c26781577de:41411</guid><dc:creator>Derik Whittaker</dc:creator><slash:comments>2</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://devlicio.us/blogs/derik_whittaker/rsscomments.aspx?PostID=41411</wfw:commentRss><wfw:comment xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://devlicio.us/blogs/derik_whittaker/commentapi.aspx?PostID=41411</wfw:comment><comments>http://devlicio.us/blogs/derik_whittaker/archive/2008/07/23/rhinomocks-new-arrange-act-assert-does-not-seem-to-work-under-mstest-odd.aspx#comments</comments><description>&lt;p&gt;&lt;strong&gt;&lt;font color="#ff0000"&gt;-- UPDATE See text in red below&amp;nbsp;--&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;Ok, I am in NO way trying to say that this is either Rhino&amp;#39;s issue or MSTest.&amp;nbsp; I am simply blogging this with the intent that someone can shed some insight as to what may be going on.&amp;nbsp; Although, since I know that the AAA logic of Rhino works with the EXACT same code under NUnit i have to believe it has something to do with the MSTest works.&lt;/p&gt; &lt;p&gt;So here is my propblem:&lt;/p&gt; &lt;p&gt;I have a test where i want to mock out and set an expectation on a repository.&amp;nbsp; When I tried the code via the AAA syntax my expectation would only return a null.&amp;nbsp; When I changed to use Record/Playback everything worked well.&amp;nbsp; Odd.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Here is the syntax for AAA (non-working)&lt;/strong&gt;&lt;/p&gt;&lt;pre class="c-sharp" name="code"&gt;var mockRepository = new MockRepository();
var mockStatusCheckRepository = mockRepository.DynamicMock();

mockStatusCheckRepository.Expect( x =&amp;gt; x.GetCustomerAuditInformation( &amp;quot;&amp;quot;, &amp;quot;&amp;quot; ) ).IgnoreArguments().Return( new CustomerAuditInformation { NeedsInitialDataCreated = true } ).Repeat.Once();
var information = mockStatusCheckRepository.GetCustomerAuditInformation( &amp;quot;&amp;quot;, &amp;quot;&amp;quot; );
// Returns null
&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;&lt;font color="#ff0000"&gt;I was able to get this working by NOT using the instance of MockRepoistory, instead using the Static Methods.&amp;nbsp; Belows Code works&lt;/font&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/p&gt;&lt;pre class="c-sharp" name="code"&gt;
var mockStatusCheckRepository = MockRepository.GenerateMock();

mockStatusCheckRepository.Expect( x =&amp;gt; x.GetCustomerAuditInformation( &amp;quot;&amp;quot;, &amp;quot;&amp;quot; ) ).IgnoreArguments().Return( new CustomerAuditInformation { NeedsInitialDataCreated = true } ).Repeat.Once();

var information = mockStatusCheckRepository.GetCustomerAuditInformation( &amp;quot;&amp;quot;, &amp;quot;&amp;quot; )
&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;&lt;font color="#ff0000"&gt;So, this may just be a case of me not fully understanding the new AAA syntax and how to use it, but I know that using the instance stuff works under NUnit... odd&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;br /&gt;Here is the syntax for the Record/Playback (working) &lt;font color="#ff0000"&gt;- Can use the AAA syntax above as well&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;&lt;pre class="c-sharp" name="code"&gt;var mockRepository = new MockRepository();
var mockStatusCheckRepository = mockRepository.DynamicMock();

using ( mockRepository.Record() )
{
    mockStatusCheckRepository.Expect( x =&amp;gt; x.GetCustomerAuditInformation( &amp;quot;&amp;quot;, &amp;quot;&amp;quot; ) ).IgnoreArguments().Return( new CustomerAuditInformation { NeedsInitialDataCreated = true } ).Repeat.Once();

}

using ( mockRepository.Playback() )
{
    var information = mockStatusCheckRepository.GetCustomerAuditInformation( &amp;quot;&amp;quot;, &amp;quot;&amp;quot; );
}
&lt;/pre&gt;
&lt;p&gt;Cany anyone shed some light on this?&amp;nbsp; Is there a way around this?&lt;/p&gt;
&lt;p&gt;Till next time,&lt;/p&gt;
&lt;p&gt;&lt;font color="#808080"&gt;&lt;strong&gt;[----- Remember to check out &lt;/strong&gt;&lt;strong&gt;&lt;a href="http://www.dimecasts.net"&gt;DimeCasts.Net&lt;/a&gt;&lt;/strong&gt;&lt;strong&gt; -----]&lt;/strong&gt;&lt;/font&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devlicio.us/aggbug.aspx?PostID=41411" width="1" height="1"&gt;</description><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/Development/default.aspx">Development</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/TDD/default.aspx">TDD</category><category domain="http://devlicio.us/blogs/derik_whittaker/archive/tags/Rhino+Mocks/default.aspx">Rhino Mocks</category></item></channel></rss>