<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/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>Dominic Hopton's Blog : Test Project</title><link>http://blogs.msdn.com/dhopton/archive/tags/Test+Project/default.aspx</link><description>Tags: Test Project</description><dc:language>en-GB</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Tips &amp; Tricks: Set the output type to EXE and give it a main method</title><link>http://blogs.msdn.com/dhopton/archive/2004/05/24/140392.aspx</link><pubDate>Tue, 25 May 2004 00:47:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:140392</guid><dc:creator>dhopton</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/dhopton/comments/140392.aspx</comments><wfw:commentRss>http://blogs.msdn.com/dhopton/commentrss.aspx?PostID=140392</wfw:commentRss><description>&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;Ok, you&amp;#8217;ve written your tests, and you want to debug them or you&amp;#8217;ve got a test failing and you can&amp;#8217;t quite see why. What are you gonna do? Well, right now we don&amp;#8217;t have built in support for debugging of tests, but there is a sneaky workaround that I use a lot.&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;Because all our projects are just derivatives of the normal projects, you can set the same options. This means that you can turn the project into an EXE type rather than just a class library. Because it&amp;#8217;s an EXE you can create a main method and allow F5 execution. Because the unit test framework works with any ol&amp;#8217; assembly you can still execute the tests from test view, even with a EXE rather than DLL.&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;One other sneaky trick I&amp;#8217;ve thought about, but not gotten round to doing is setting mstest.exe as the command line for the debug session, and seeing if that would work. But As I say, I&amp;#8217;ve not tried it yet &amp;#8211; if It works, please share :)&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;UPDATE: Sorry, I should have made it clearer, this is a Tip for the May CTP - we're intending on adding full support for debugging tests, it's just it's not in there right now.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=140392" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/dhopton/archive/tags/Visual+Studio+Team+System/default.aspx">Visual Studio Team System</category><category domain="http://blogs.msdn.com/dhopton/archive/tags/Test+Project/default.aspx">Test Project</category></item><item><title>No! My Run config got toasted!</title><link>http://blogs.msdn.com/dhopton/archive/2004/05/24/140390.aspx</link><pubDate>Tue, 25 May 2004 00:46:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:140390</guid><dc:creator>dhopton</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/dhopton/comments/140390.aspx</comments><wfw:commentRss>http://blogs.msdn.com/dhopton/commentrss.aspx?PostID=140390</wfw:commentRss><description>&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;Another problem with the run configuration is that the template runconfig (The one that gets added to new solutions) can easily become overwritten with your user one, thus potentially screwing up test execution for all projects AND new projects. This only happens in a specific situation, but sadly this is a very common situation.&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;So, what happens? Well, when you create a new Test Project (not Empty Test project) you are prompted in the wizard to add a default run config to the solution. If you select this option the run config is added to the solution, and you&amp;#8217;re good to go. The only problem here is the bug that adds the run config as a link rather than copying to the solution directory. Because of this, all changes to the run config made in this situation will result in those changes being reflected across ALL solutions that were created in the same way, and ALL new projects where you add a run config in any manner to the solution.&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;You can work around this simply by not using the wizard to add a run config to the solution, and instead letting the Run Config Dialog add the run config when you first run a test.&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;When you first go to execute tests when there is no run config associated with the solution, the dialog will not list anything in the &amp;#8220;Run Configuration&amp;#8221; Drop down &amp;#8211; this is fine. Click the browse button, and select localtestrun.rcg. Click Open, then click OK. When prompted &amp;#8220;Do you want to add this to the solution&amp;#8221; select Yes, and all will go fine and dandy. If the file is not listed, navigate to %ProgramFiles%\Microsoft Visual Studio 8\Enterprise Developer Tools\Testing Tools\TestProjectCommon\Templates\RunConfig\1033 and the file should be located there.&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;If you manage to corrupt your localtestrun.rcg that resides in the project directory, you can just copy it off the install media again and you&amp;#8217;ll be up and running again. This can be found in the %ProgramFiles%\Microsoft Visual Studio 8\Enterprise Developer Tools\Testing Tools\TestProjectCommon\Templates\RunConfig\1033 directory on the media &amp;#8211; just copy this to the same path on the hard disk.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=140390" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/dhopton/archive/tags/Visual+Studio+Team+System/default.aspx">Visual Studio Team System</category><category domain="http://blogs.msdn.com/dhopton/archive/tags/Test+Project/default.aspx">Test Project</category><category domain="http://blogs.msdn.com/dhopton/archive/tags/General/default.aspx">General</category></item><item><title>I turned off code coverage and I can’t run my tests anymore!</title><link>http://blogs.msdn.com/dhopton/archive/2004/05/24/140389.aspx</link><pubDate>Tue, 25 May 2004 00:43:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:140389</guid><dc:creator>dhopton</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/dhopton/comments/140389.aspx</comments><wfw:commentRss>http://blogs.msdn.com/dhopton/commentrss.aspx?PostID=140389</wfw:commentRss><description>&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;This is a problem we only found out after we&amp;#8217;d sent off the DVDs to be pressed, and turns out to easy to repro, but also easy to workaround. It&amp;#8217;s also got a slightly strange workflow compared to the way we think a lot of people will be using run configs initially.&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;If you enable code coverage and then subsequently disable it &amp;#8211; all through the Edit Run Configuration dialog (or opening &amp;amp; saving from the Run test run config dialog), you will possibly find that when you run your tests you will see that the test result is error/fail and the message is &amp;#8220;FileNotFoundException&amp;#8221;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;or &amp;#8220;MethodNotFound&amp;#8221;.&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;How can you workaround this problem and get back to running your unit tests? Well, there are two ways:&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo1; tab-stops: list .5in"&gt;&lt;SPAN style="mso-list: Ignore"&gt;a)&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;Copy the localtestrun.rcg from the product directory over the one in your solution&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt 0.5in; TEXT-INDENT: -0.25in; mso-list: l0 level1 lfo1; tab-stops: list .5in"&gt;&lt;SPAN style="mso-list: Ignore"&gt;b)&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;Edit the .rcg file for your solution so that the XML element isNewLocalDeployment is set to false rather than true.&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;If you do either of these you will need to close your solution and re-open it to see the changes.&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;There is a simple way to avoid this happening. When working with run configuration, don&amp;#8217;t use the &amp;#8220;Edit Run Configuration&amp;#8221; button on the toolbar to enable/disable code coverage. This is because using this dialog saves the changes to disk when you click OK &amp;amp; keep the changes. When you change settings in the Run Configuration dialog shown when you execute tests, the changes are only saved if you explicitly save them. Because of this subtle difference, you can change settings at runtime without screwing anything up.&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;Another option of source is to save the code coverage enabled runconfig to a separate file and just swap between them when you need to have or not have code coverage information.&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;One last thing on this topic &amp;#8211; you may have a problem with a) because of another bug, which I&amp;#8217;ll cover in another blogsicle.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=140389" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/dhopton/archive/tags/Visual+Studio+Team+System/default.aspx">Visual Studio Team System</category><category domain="http://blogs.msdn.com/dhopton/archive/tags/Test+Project/default.aspx">Test Project</category><category domain="http://blogs.msdn.com/dhopton/archive/tags/General/default.aspx">General</category></item></channel></rss>