<?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>Clark Sell : Testing</title><link>http://blogs.msdn.com/csell/archive/tags/Testing/default.aspx</link><description>Tags: Testing</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Bye Bye VSMDI</title><link>http://blogs.msdn.com/csell/archive/2006/11/06/bye-bye-vsmdi.aspx</link><pubDate>Mon, 06 Nov 2006 17:39:04 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:999625</guid><dc:creator>csell</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/csell/comments/999625.aspx</comments><wfw:commentRss>http://blogs.msdn.com/csell/commentrss.aspx?PostID=999625</wfw:commentRss><description>&lt;p&gt;That blasted VSMDI file.&amp;nbsp; Well Buck, Tom and crew did it.&amp;nbsp; They have finally given us the ability to run tests ( albeit all&amp;nbsp;) found in an assembly regardless of test lists. &amp;nbsp;&lt;a title="http://blogs.msdn.com/buckh/archive/2006/11/04/how-to-run-tests-without-test-metadata-files-and-test-lists-vsmdi-files.aspx" href="http://blogs.msdn.com/buckh/archive/2006/11/04/how-to-run-tests-without-test-metadata-files-and-test-lists-vsmdi-files.aspx"&gt;http://blogs.msdn.com/buckh/archive/2006/11/04/how-to-run-tests-without-test-metadata-files-and-test-lists-vsmdi-files.aspx&lt;/a&gt;&amp;nbsp;I am currently integrating this into TfsAlert and will post my findings.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=999625" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/csell/archive/tags/Testing/default.aspx">Testing</category></item><item><title>Simple NMock Working Sample</title><link>http://blogs.msdn.com/csell/archive/2006/01/23/simple-nmock-working-sample.aspx</link><pubDate>Tue, 24 Jan 2006 05:17:47 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:516583</guid><dc:creator>csell</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/csell/comments/516583.aspx</comments><wfw:commentRss>http://blogs.msdn.com/csell/commentrss.aspx?PostID=516583</wfw:commentRss><description>&lt;P&gt;Based on some conversations I had today, here is a simple&amp;nbsp;&lt;A href="http://nmock.org"&gt;NMock&lt;/A&gt; example.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://csell.net/content/binary/NMockExample.zip"&gt;NMockExample.zip (17.19 KB)&lt;/A&gt;&lt;/P&gt;&lt;img width="0" height="0" src="http://csell.net/cptrk.ashx?id=05d0a373-3a56-42ae-9e7b-daefa360c933"&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=516583" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/csell/archive/tags/Testing/default.aspx">Testing</category></item><item><title>Converting a csproj into a test csproj</title><link>http://blogs.msdn.com/csell/archive/2006/01/21/converting-a-csproj-into-a-test-csproj.aspx</link><pubDate>Sat, 21 Jan 2006 17:36:27 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:515738</guid><dc:creator>csell</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/csell/comments/515738.aspx</comments><wfw:commentRss>http://blogs.msdn.com/csell/commentrss.aspx?PostID=515738</wfw:commentRss><description>&lt;P dir=ltr style="MARGIN-RIGHT: 0px"&gt;&lt;STRONG&gt;Short answer.&lt;/STRONG&gt;&lt;/P&gt;
&lt;P dir=ltr style="MARGIN-RIGHT: 0px"&gt;It's as simple as adding one line to your csproj which in turn tells the IDE to treat that project like a test project.&amp;nbsp; Add the following line to your main PropertyGroup:&lt;/P&gt;
&lt;BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px"&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;lt;ProjectGuid&amp;gt;{04082EBA-C85C-4336-B3FD-9891096BAA0F}&amp;lt;/ProjectGuid&amp;gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P dir=ltr&gt;&lt;SPAN style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;FONT face=Verdana color=#003300 size=2&gt;Then just reference Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll and you are on your way.&amp;nbsp; &lt;SPAN style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;FONT face=Verdana color=#003300 size=2&gt;Be sure to verify that Guid between releases.&amp;nbsp; &lt;/FONT&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P dir=ltr&gt;&lt;SPAN style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;FONT face=Verdana color=#003300 size=2&gt;&lt;STRONG&gt;Long Answer.&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P dir=ltr&gt;&lt;SPAN style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;FONT face=Verdana color=#003300 size=2&gt;When I start a project I create the base set of known assemblies that project will need.&amp;nbsp; I also add an additional test project which will contain any Scenario, Load&amp;nbsp;and Stored Procedure tests.&amp;nbsp; Then I convert all assemblies to test projects.&amp;nbsp; I am a firm believer in&amp;nbsp;Test Driven Development.&amp;nbsp; IMHO it is the only way to properly write code.&amp;nbsp; Having said that&amp;nbsp;over the years I have developed my own set of TDD practices; one of which is the physical placement of your unit test&amp;nbsp;classes in the assembly their testing.&amp;nbsp; Why? Well I will explain that in a future post call Unit Testing with Partial Classes.&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P dir=ltr&gt;&lt;SPAN style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;FONT face=Verdana color=#003300 size=2&gt;With any decision there are of course trade-offs. In this case the trade-off is around the IDE interaction with hosting type projects, ie exe or&amp;nbsp;web.&amp;nbsp; After you convert an exe to a test project, when&amp;nbsp;you decide to run ( F5 ) it will actually fire off Test Manager rather than the launch app.&amp;nbsp; If you are a TDD&amp;nbsp;bigot like me&amp;nbsp;this is actually the&amp;nbsp;correct action; if your not, I know your already complaining.&amp;nbsp;&amp;nbsp;BUT all is not lost!&amp;nbsp;&amp;nbsp;There is a little tool us TDD bigots keep&amp;nbsp;in our back pocket at all times, &lt;A href="http://testdriven.net/"&gt;TestDriven.Net&lt;/A&gt;.&amp;nbsp; This is an Visual Studio add-in and it allows you to execute your unit tests with just a right click.&amp;nbsp; If you choose to use this tool it isn't necessary to convert your project to a test project but rather just reference the Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll.&amp;nbsp; This will allow you to fire your app as intended and run your tests with the same project configuration.&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P dir=ltr&gt;&lt;SPAN style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;FONT face=Verdana color=#003300 size=2&gt;&lt;STRONG&gt;Disclaimer:&lt;/STRONG&gt; this is not a Microsoft recommend practice.&amp;nbsp; You can find more information about the Visual Studio Team System Testing Framework &lt;A href="http://msdn2.microsoft.com/en-us/library/ms304624(en-us,vs.80).aspx"&gt;here&lt;/A&gt;.&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;img width="0" height="0" src="http://csell.net/cptrk.ashx?id=329398b3-1992-455e-969e-79800ba386c7"&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=515738" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/csell/archive/tags/Testing/default.aspx">Testing</category></item><item><title>Unit Testing with Anonymous Methods</title><link>http://blogs.msdn.com/csell/archive/2006/01/20/unit-testing-with-anonymous-methods.aspx</link><pubDate>Sat, 21 Jan 2006 04:19:45 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:515612</guid><dc:creator>csell</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/csell/comments/515612.aspx</comments><wfw:commentRss>http://blogs.msdn.com/csell/commentrss.aspx?PostID=515612</wfw:commentRss><description>&lt;P&gt;Mark Seemann recently published a great post demonstrating the&amp;nbsp;use of &lt;A href="http://msdn2.microsoft.com/en-us/library/0yw3tz5k.aspx"&gt;anonymous methods&lt;/A&gt; in unit testing events.&amp;nbsp;&amp;nbsp;&lt;A href="http://blogs.msdn.com/ploeh/archive/2006/01/19/TestingEventsUsingAnonymousMethods.aspx"&gt;Testing Events Using&amp;nbsp;Anonymous Methods&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;That just rocks, thanks Mark!&lt;/P&gt;&lt;img width="0" height="0" src="http://csell.net/cptrk.ashx?id=271b29fb-b6aa-4b36-b732-bbf3d5051c81"&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=515612" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/csell/archive/tags/Testing/default.aspx">Testing</category></item><item><title>Multiple Test Runs in one BuildType</title><link>http://blogs.msdn.com/csell/archive/2006/01/17/multiple-test-runs-in-one-buildtype.aspx</link><pubDate>Wed, 18 Jan 2006 08:51:14 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:514168</guid><dc:creator>csell</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/csell/comments/514168.aspx</comments><wfw:commentRss>http://blogs.msdn.com/csell/commentrss.aspx?PostID=514168</wfw:commentRss><description>&lt;P&gt;&lt;SPAN style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;FONT face=Verdana&gt;If you are using TeamBuild then this post is for you.&amp;nbsp; &lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;FONT face=Verdana&gt;In TeamExplorer when you create a new&amp;nbsp;build type it will create a&amp;nbsp;*.proj file.&amp;nbsp; During the creation of&amp;nbsp;this build type, you will be asked which TestLists you would like executed in that build type.&amp;nbsp;&amp;nbsp;Once completed if you open&amp;nbsp;that proj file, you will see an item group that looks something like the following:&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;lt;ItemGroup&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;lt;MetaDataFile Include=&lt;SPAN style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"$(SolutionRoot)\TestProject1\TestProject1.vsmdi"&lt;/SPAN&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;TestList&amp;gt;TestList1;TestList2&amp;lt;/TestList&amp;gt;&lt;BR&gt;&amp;nbsp; &amp;lt;/MetaDataFile&amp;gt;&lt;BR&gt;&amp;lt;/ItemGroup&amp;gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;FONT face=Verdana&gt;For this build type&amp;nbsp;there are actually 2&amp;nbsp;different&amp;nbsp;TestLists, TestList1 and TestList2.&amp;nbsp; These&amp;nbsp;TestLists will get executed and reported on in the build.&amp;nbsp; With the out of box ItemGroup configuration both&amp;nbsp;lists will actually roll up into one&amp;nbsp;set of test results; but what if you wanted to&amp;nbsp;to actually have multiple test runs for a given build.&amp;nbsp;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;SPAN style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;FONT face=Verdana&gt;We can make a very slight modification to that generated code block and actually get a separate&amp;nbsp;test run per test list.&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;lt;PropertyGroup&amp;gt;&lt;BR&gt;&amp;nbsp; &amp;lt;VsmdiPath&amp;gt;$(SolutionRoot)\TestProject1\TestProject1.vsmdi&amp;lt;/VsmdiPath&amp;gt;&lt;BR&gt;&amp;lt;/PropertyGroup&amp;gt;&lt;BR&gt;&lt;BR&gt;&amp;lt;ItemGroup&amp;gt;&lt;BR&gt;&amp;nbsp; &amp;lt;MetaDataFile Include=&lt;SPAN style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"$(VsmdiPath)"&lt;/SPAN&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;TestList&amp;gt;TestList1&amp;lt;/TestList&amp;gt;&lt;BR&gt;&amp;nbsp; &amp;lt;/MetaDataFile&amp;gt;&lt;BR&gt;&lt;BR&gt;&amp;nbsp; &amp;lt;MetaDataFile Include=&lt;SPAN style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"$(VsmdiPath)"&lt;/SPAN&gt;&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;TestList&amp;gt;TestList2&amp;lt;/TestList&amp;gt;&lt;BR&gt;&amp;nbsp; &amp;lt;/MetaDataFile&amp;gt;&lt;BR&gt;&amp;lt;/ItemGroup&amp;gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;FONT face=Verdana&gt;More to come....&lt;/FONT&gt;&lt;/SPAN&gt;&lt;BR&gt;&lt;/P&gt;&lt;/SPAN&gt;&lt;img width="0" height="0" src="http://csell.net/cptrk.ashx?id=2984f17f-3690-441f-86c5-cb541b9212bf"&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=514168" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/csell/archive/tags/Testing/default.aspx">Testing</category></item><item><title>ExpectedException Exception Message Validation</title><link>http://blogs.msdn.com/csell/archive/2006/01/16/expectedexception-exception-message-validation.aspx</link><pubDate>Mon, 16 Jan 2006 18:28:06 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:513325</guid><dc:creator>csell</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/csell/comments/513325.aspx</comments><wfw:commentRss>http://blogs.msdn.com/csell/commentrss.aspx?PostID=513325</wfw:commentRss><description>&lt;P&gt;&lt;SPAN style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;FONT face=Verdana&gt;While you cannot validate you exception's message in the ExpectedException attribute all is not lost.&amp;nbsp; Lets walk through three scenarios. &lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;FONT face=Verdana&gt;&lt;SPAN style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;FONT face=Verdana&gt;In all three tests you will see an Assert.Fail in the try block.&amp;nbsp; You need this statement in case the target doesn't throw any exceptions, therefor failing the test.&amp;nbsp; The first example is a passing test, throw and exception with a message, catch it and compare the message string.&amp;nbsp;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P dir=ltr style="MARGIN-RIGHT: 0px"&gt;&lt;SPAN style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;[TestMethod]&lt;BR&gt;&lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;public&lt;/SPAN&gt; &lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;void&lt;/SPAN&gt; PassingException()&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;BR&gt;&lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;const&lt;/SPAN&gt; &lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;string&lt;/SPAN&gt; expectedExceptionMessage &lt;SPAN style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/SPAN&gt; &lt;SPAN style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"Foobar Message"&lt;/SPAN&gt;;&lt;BR&gt;&lt;BR&gt;&lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;try&lt;/SPAN&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;BR&gt;&lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;throw&lt;/SPAN&gt; &lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;new&lt;/SPAN&gt; ApplicationException( expectedExceptionMessage );&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Assert.Fail( &lt;SPAN style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"Expected an exception to get thrown by target"&lt;/SPAN&gt; );&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;BR&gt;&lt;BR&gt;&lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;catch&lt;/SPAN&gt; ( ApplicationException ex )&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Assert.AreEqual&amp;lt;&lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;string&lt;/SPAN&gt;&amp;gt;( expectedExceptionMessage, ex.Message );&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;BR&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P dir=ltr style="MARGIN-RIGHT: 0px"&gt;&lt;SPAN style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;FONT face=Verdana&gt;Here we see the&amp;nbsp;same test failing only because the message contained in the exception is different.&lt;BR&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;[TestMethod]&lt;BR&gt;&lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;public&lt;/SPAN&gt; &lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;void&lt;/SPAN&gt; FailingOnExceptionMessage()&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;BR&gt;&lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;const&lt;/SPAN&gt; &lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;string&lt;/SPAN&gt; expectedExceptionMessage &lt;SPAN style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/SPAN&gt; &lt;SPAN style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"Foobar Message"&lt;/SPAN&gt;;&lt;BR&gt;&lt;BR&gt;&lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;try&lt;/SPAN&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;BR&gt;&lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;throw&lt;/SPAN&gt; &lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;new&lt;/SPAN&gt; ApplicationException( &lt;SPAN style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"Invalid"&lt;/SPAN&gt; );&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Assert.Fail( &lt;SPAN style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"Expected an exception to get thrown by target"&lt;/SPAN&gt; );&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;BR&gt;&lt;BR&gt;&lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;catch&lt;/SPAN&gt; ( ApplicationException ex )&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Assert.AreEqual&amp;lt;&lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;string&lt;/SPAN&gt;&amp;gt;( expectedExceptionMessage, ex.Message );&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana&gt;While this last test follows the same pattern seen above the test is really only testing for the type of exception being throw.&amp;nbsp; This should be refactored to use the ExpectedException attribute.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;[TestMethod]&lt;BR&gt;&lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;public&lt;/SPAN&gt; &lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;void&lt;/SPAN&gt; FailingOnExceptionType()&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;BR&gt;&lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;const&lt;/SPAN&gt; &lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;string&lt;/SPAN&gt; expectedExceptionMessage &lt;SPAN style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/SPAN&gt; &lt;SPAN style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"Foobar Message"&lt;/SPAN&gt;;&lt;BR&gt;&lt;BR&gt;&lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;try&lt;/SPAN&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;BR&gt;&lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;throw&lt;/SPAN&gt; &lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;new&lt;/SPAN&gt; Exception( expectedExceptionMessage );&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Assert.Fail( &lt;SPAN style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"Expected an exception to get thrown by target"&lt;/SPAN&gt; );&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;BR&gt;&lt;BR&gt;&lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;catch&lt;/SPAN&gt; ( ApplicationException ex )&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;catch&lt;/FONT&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Assert.Fail(&amp;nbsp;&lt;SPAN style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"Incorrect Exception type was thrown by target"&lt;/SPAN&gt;&amp;nbsp;);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;FONT face=Verdana&gt;Same test refactored, this test still fails but only to illustrate that example.&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;[TestMethod, ExpectedException ( &lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;typeof&lt;/SPAN&gt; ( ApplicationException) )]&lt;BR&gt;&lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;public&lt;/SPAN&gt; &lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;void&lt;/SPAN&gt; FailingOnExceptionType()&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;BR&gt;&lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;throw&lt;/SPAN&gt; &lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;new&lt;/SPAN&gt; Exception( &lt;SPAN style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"..."&lt;/SPAN&gt; );&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/SPAN&gt;&lt;/P&gt;&lt;/SPAN&gt;&lt;img width="0" height="0" src="http://csell.net/cptrk.ashx?id=b82c677f-8644-4200-adb0-1b02d80c7905"&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=513325" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/csell/archive/tags/Testing/default.aspx">Testing</category></item><item><title>ExpectedException might not be what you've expected</title><link>http://blogs.msdn.com/csell/archive/2006/01/13/expectedexception-might-not-be-what-you-ve-expected.aspx</link><pubDate>Sat, 14 Jan 2006 20:34:50 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:512901</guid><dc:creator>csell</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/csell/comments/512901.aspx</comments><wfw:commentRss>http://blogs.msdn.com/csell/commentrss.aspx?PostID=512901</wfw:commentRss><description>&lt;P&gt;If you've switched from NUnit to the VSTS Unit Testing then I am pretty sure you've used the &lt;A href="http://msdn2.microsoft.com/en-us/library/microsoft.visualstudio.testtools.unittesting.expectedexceptionattribute.aspx"&gt;ExpectedException&lt;/A&gt; attribute. If you haven't it looks something like this:&lt;/P&gt;
&lt;BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px"&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;[ExpectedException( &lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;typeof&lt;/SPAN&gt;( ApplicationException ), &lt;SPAN style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"Message"&lt;/SPAN&gt; )]&lt;/SPAN&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;FONT face=Verdana color=#003300 size=2&gt;Using it with a test would look like the following:&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;SPAN style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;
&lt;BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px"&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;[TestMethod, ExpectedException( &lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;typeof&lt;/SPAN&gt; ( ApplicationException ) ) ]&lt;BR&gt;&lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;public&lt;/SPAN&gt; &lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;void&lt;/SPAN&gt; ut1()&lt;BR&gt;{&lt;BR&gt;&lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;throw&lt;/SPAN&gt; &lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;new&lt;/SPAN&gt; ApplicationException();&lt;BR&gt;}&lt;BR&gt;&lt;BR&gt;[TestMethod, ExpectedException( &lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;typeof&lt;/SPAN&gt;( ApplicationException ), &lt;SPAN style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"foo"&lt;/SPAN&gt; )]&lt;BR&gt;&lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;public&lt;/SPAN&gt; &lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;void&lt;/SPAN&gt; ut2()&lt;BR&gt;{&lt;BR&gt;&lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;throw&lt;/SPAN&gt; &lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;new&lt;/SPAN&gt; ApplicationException(&lt;SPAN style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"bar"&lt;/SPAN&gt;);&lt;BR&gt;}&lt;BR&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;FONT face=Verdana color=#003300 size=2&gt;You would naturally expect&amp;nbsp;test ut1 to pass and ut2 to fail.&amp;nbsp; ut2 should fail&amp;nbsp;on the bases that the message&amp;nbsp;contained within the exception was in fact&amp;nbsp;different.&amp;nbsp; Not true.&amp;nbsp; Both actually pass and not because of a bug but rather a new feature introduced to the attribute.&amp;nbsp; The &lt;A href="http://msdn2.microsoft.com/en-us/library/microsoft.visualstudio.testtools.unittesting.expectedexceptionattribute.message.aspx"&gt;Message&lt;/A&gt;&amp;nbsp;property is actually&amp;nbsp;a message that prints&amp;nbsp;out with the test when it fails;&amp;nbsp;just like the optional&amp;nbsp;message property you find on all of the &lt;A href="http://msdn2.microsoft.com/en-us/library/ms245282(en-US,VS.80).aspx"&gt;Assert methods&lt;/A&gt;.&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;SPAN style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;Assert.IsTrue( &lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;false&lt;/SPAN&gt; == &lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;true&lt;/SPAN&gt;, &lt;SPAN style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"Developer put explanation if this test was to fail"&lt;/SPAN&gt; );&lt;/SPAN&gt;&lt;/P&gt;&lt;/SPAN&gt;&lt;FONT face=Verdana color=#003300 size=2&gt;&lt;/FONT&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;FONT face=Verdana color=#003300 size=2&gt;That message will print with the output of the test like so: &lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px"&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;FONT face=Verdana color=#003300 size=2&gt;Error&amp;nbsp;1&amp;nbsp;TestCase 'ExpectedExceptionTest.ExpectedException.ut3' failed: &lt;FONT color=#ff0000&gt;Assert.IsTrue failed. Developer put explanation if this test was to fail&lt;BR&gt;&lt;/FONT&gt;at ExpectedExceptionTest.ExpectedException.ut3() in C:\MyPrograms\ExpectedException\ExpectedExceptionTest\ExpectedException.cs:line 26&amp;nbsp;C:\MyPrograms\ExpectedException\ExpectedExceptionTest\ExpectedException.cs&amp;nbsp;26&amp;nbsp;&lt;BR&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;FONT face=Verdana color=#003300 size=2&gt;Lets correct ut2:&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;SPAN style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;FONT face=Verdana color=#003300 size=2&gt;
&lt;BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px"&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;[TestMethod, ExpectedException( &lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;typeof&lt;/SPAN&gt;( ApplicationException ), &lt;SPAN style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"I failed because I am looking for the wrong excpeption type"&lt;/SPAN&gt; )]&lt;BR&gt;&lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;public&lt;/SPAN&gt; &lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;void&lt;/SPAN&gt; newUt2()&lt;BR&gt;{&lt;BR&gt;&lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;throw&lt;/SPAN&gt; &lt;SPAN style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;new&lt;/SPAN&gt; Exception( &lt;SPAN style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"foobar"&lt;/SPAN&gt; );&lt;BR&gt;}&lt;/SPAN&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;/FONT&gt;&lt;/SPAN&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;FONT face=Verdana color=#003300 size=2&gt;This will in fact fail because the Exception type thrown was different.&amp;nbsp; When it fails we will see that message in the output.&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;FONT face=Verdana color=#003300 size=2&gt;Having said all that, there is in fact a&amp;nbsp;bug.&amp;nbsp; When you run a test with that &lt;A href="http://msdn2.microsoft.com/en-us/library/microsoft.visualstudio.testtools.unittesting.expectedexceptionattribute.aspx"&gt;ExpectedException&lt;/A&gt;&amp;nbsp;attribute in&amp;nbsp;Visual Studio you will not see the message on the failure output; if you run it in MSTest.exe you will.&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;/SPAN&gt;&lt;A href="http://csell.net/content/binary/ExpectedException.cs"&gt;ExpectedException.cs (.75 KB)&lt;/A&gt;&lt;/P&gt;&lt;img width="0" height="0" src="http://csell.net/cptrk.ashx?id=27bc17dd-36eb-4c07-86fa-dbb41dfadfca"&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=512901" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/csell/archive/tags/Testing/default.aspx">Testing</category></item><item><title>MSTest.exe</title><link>http://blogs.msdn.com/csell/archive/2006/01/14/mstest-exe.aspx</link><pubDate>Sat, 14 Jan 2006 18:12:01 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:512874</guid><dc:creator>csell</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/csell/comments/512874.aspx</comments><wfw:commentRss>http://blogs.msdn.com/csell/commentrss.aspx?PostID=512874</wfw:commentRss><description>&lt;P&gt;Stumbled across a command line tool ( MSTest ) which executes your VSTS test list. You can call if from a Visual Studio command prompt or @ C:\Program Files\Microsoft Visual Studio 8\Common7\IDE&lt;/P&gt;
&lt;P&gt;Upon execution this will create the same output as if you executed your tests inside of Visual Studio.&lt;/P&gt;&lt;img width="0" height="0" src="http://csell.net/cptrk.ashx?id=dc15077d-65ce-4743-8ad7-1e46c57d4186"&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=512874" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/csell/archive/tags/Testing/default.aspx">Testing</category></item></channel></rss>