<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Jeff Wilcox &#187; Testing</title>
	<atom:link href="http://www.jeff.wilcox.name/topics/dev/testing/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.jeff.wilcox.name</link>
	<description>Silverlight, rich client apps and web development</description>
	<lastBuildDate>Wed, 18 Aug 2010 01:33:15 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Updated Silverlight Unit Test Framework bits for Windows Phone and Silverlight 3</title>
		<link>http://www.jeff.wilcox.name/2010/05/sl3-utf-bits/</link>
		<comments>http://www.jeff.wilcox.name/2010/05/sl3-utf-bits/#comments</comments>
		<pubDate>Thu, 27 May 2010 21:02:52 +0000</pubDate>
		<dc:creator>Jeff Wilcox</dc:creator>
				<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Silverlight Toolkit]]></category>
		<category><![CDATA[Testing]]></category>
		<category><![CDATA[Windows Phone]]></category>

		<guid isPermaLink="false">http://www.jeff.wilcox.name/2010/05/sl3-utf-bits/</guid>
		<description><![CDATA[Here's the same unit test framework from the April 2010 Silverlight Toolkit, built for Windows Phone and SL3 developers only.]]></description>
			<content:encoded><![CDATA[<p>Here are updated quasi-official unit test framework bits for Silverlight 3 and Windows Phone developers. These are <strong>not</strong> intended for Silverlight 4 developers, since the same framework built for SL4 is included in the <a href="http://silverlight.codeplex.com/">April 2010 Silverlight Toolkit</a>.</p>
<p>This brings the <a href="http://www.jeff.wilcox.name/2010/05/new-2010-test-framework/">new features</a> from the Silverlight 4 version to developers who have a business reason to continue with Silverlight 3 development for the time being:</p>
<ul>
<li>Updated user interface</li>
<li>Integrated “tag expression” support for selecting subsets of tests to run</li>
<li>Performance improvements</li>
<li>Removal of dependencies on XLinq and System.Windows.Browser assemblies</li>
</ul>
<p>These are also the bits you want for Windows Phone testing.</p>
<h4>Why wasn’t there one for Silverlight 3 already?</h4>
<p>Since the April 2010 toolkit release was targeted for Silverlight 4 developers only, these bits were not released for version 3 (though were built from the same source).</p>
<h4>Why doesn’t the April 2010 toolkit work for Windows Phone development &amp; testing?</h4>
<p>The Windows Phone development environment is based on a version of Silverlight 3 today, and so that means that you need to use Silverlight 3 binaries and class libraries when re-using Silverlight apps and code – <em>not</em> Silverlight 4.</p>
<p>These bits work well for phone developers and replace the older bits I had posted to my <a href="http://www.jeffatmix.com/">MIX talk site</a>.</p>
<h4>Download the binaries</h4>
<p>[<a href="http://media.jeff.wilcox.name/blog/ut/SL3_UTF_May.zip"><strong>Silverlight 3 binaries for the Silverlight Unit Test Framework</strong></a>, Zip 452KB]    <br />You may need to ‘unlock’ the binaries for security reasons once downloading and extracting the assemblies from the .Zip. To do this, right-click on the file and select the ‘Unlock’ button.</p>
<p>These binaries are strong named as before, but are <em>not</em> Authenticode signed, so they are not official. This helps work around some Windows Phone signing issues I’ve heard reports of.</p>
<p>Hope this helps,   <br />Jeff</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jeff.wilcox.name/2010/05/sl3-utf-bits/feed/</wfw:commentRss>
		<slash:comments>19</slash:comments>
		</item>
		<item>
		<title>Deep dive on Silverlight unit testing at Tech Ed next month</title>
		<link>http://www.jeff.wilcox.name/2010/05/silverlight-testing-at-teched-2010/</link>
		<comments>http://www.jeff.wilcox.name/2010/05/silverlight-testing-at-teched-2010/#comments</comments>
		<pubDate>Tue, 11 May 2010 18:30:12 +0000</pubDate>
		<dc:creator>Jeff Wilcox</dc:creator>
				<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[TechEd]]></category>
		<category><![CDATA[Testing]]></category>

		<guid isPermaLink="false">http://www.jeff.wilcox.name/2010/05/silverlight-testing-at-teched-2010/</guid>
		<description><![CDATA[Jeff Wilcox will be presenting a 200-level deep dive talk on Silverlight unit testing at the TechEd North America 2010 conference next month in New Orleans.]]></description>
			<content:encoded><![CDATA[<p>In about a month I will be presenting a 200-level session on Silverlight unit testing at <a href="http://northamerica.msteched.com/">Tech Ed North America in New Orleans</a>. The talk will be an hour with questions, so you can arrive new to Silverlight testing and leave with all the tools you need to be successful in building high-quality applications with the right level of regression coverage that your management can smile about.</p>
<p>The session will be more comprehensive than the overview talk I presented at <a href="http://www.jeff.wilcox.name/2010/03/mix10-testing-talk-online/">MIX 10 (which is available as a free online video stream now)</a>.</p>
<p><img style="border-bottom: 0px; border-left: 0px; display: inline; margin-left: 0px; border-top: 0px; margin-right: 0px; border-right: 0px" title="TechEd_2010" border="0" alt="TechEd_2010" src="http://www.jeff.wilcox.name/wp-content/uploads/2010/05/TechEd_2010.png" width="300" height="123" /> </p>
<p><a href="http://northamerica.msteched.com/topic/list?keyword=WEB205">Click here to view the talk information</a> on the Tech Ed site. The tentative information is as follows, but please double-check with the conference schedule builder before showing up:</p>
<blockquote><p><a href="http://northamerica.msteched.com/topic/list?keyword=WEB205"><strong>Unit Testing in Microsoft Silverlight</strong></a>       <br />Wednesday, June 9, 2010       <br />11:45 AM – 1:00 PM       <br />Room 287       <br />Session Code WEB205       <br /><a title="http://northamerica.msteched.com/topic/list?keyword=WEB205" href="http://northamerica.msteched.com/topic/list?keyword=WEB205">http://northamerica.msteched.com/topic/list?keyword=WEB205</a></p>
</blockquote>
<p>Hope to see some friendly faces in the audience! I’ll be up there in some sort of speaker polo shirt uniform with khakis, apparently this conference isn’t quite as trendy and cool as MIX in Vegas <img src='http://www.jeff.wilcox.name/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> .</p>
<p>If you’re going to be attending Tech Ed, I’d appreciate any early comments you have as there is still time to shape the content of the talk.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jeff.wilcox.name/2010/05/silverlight-testing-at-teched-2010/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Silverlight Unit Test Framework: New version in the April 2010 Silverlight Toolkit</title>
		<link>http://www.jeff.wilcox.name/2010/05/new-2010-test-framework/</link>
		<comments>http://www.jeff.wilcox.name/2010/05/new-2010-test-framework/#comments</comments>
		<pubDate>Mon, 03 May 2010 22:26:06 +0000</pubDate>
		<dc:creator>Jeff Wilcox</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Silverlight Toolkit]]></category>
		<category><![CDATA[Testing]]></category>

		<guid isPermaLink="false">http://www.jeff.wilcox.name/2010/05/new-2010-test-framework/</guid>
		<description><![CDATA[The latest release of the Silverlight Toolkit contains the new Silverlight Unit Test Framework, with a new modern user interface, out-of-browser support, and performance improvements.]]></description>
			<content:encoded><![CDATA[<p>In April we released a new version of the <a href="http://silverlight.codeplex.com/releases/view/43528">Silverlight Toolkit</a> for targeting Microsoft Silverlight 4. This release contains a new version of the Silverlight Unit Test Framework. Key improvements come in user interface, Silverlight 4 support, and performance.</p>
<h3>Rich, modern user interface</h3>
<p>The user interface no longer uses the antiquated HTML DOM bridge for displaying results, but now is a data bound, rich Silverlight application itself.</p>
<p><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="NewTestFramework" border="0" alt="NewTestFramework" src="http://www.jeff.wilcox.name/wp-content/uploads/2010/05/NewTestFramework.png" width="685" height="579" /></p>
<p>Rich results information is available, and a tree view control allows you to select results to be included in a test report that can be copied to the clipboard. Failures are automatically selected.</p>
<p>The results pane includes information about the tests that ran, as well as detailed information for failures.</p>
<p>Descriptive text helps identify negative tests, known test issues and bugs, and other important metadata that was not always exposed in the previous test framework.</p>
<h4>Integrated tag expression support</h4>
<p>The startup experience now allows you to enter a tag expression to select which tests to run, or not to run. You can add the Tag(“”) attribute to any test methods or classes to define your own tags. Also, the full and short names of tests and classes implicitly become test tags, as well as priorities.</p>
<p><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="TagExpressionsEditor" border="0" alt="TagExpressionsEditor" src="http://www.jeff.wilcox.name/wp-content/uploads/2010/05/TagExpressionsEditor.png" width="685" height="375" /> </p>
<p>This means that you can define tags such as:</p>
<table border="0" cellspacing="0" cellpadding="2" width="600">
<tbody>
<tr>
<td valign="top" width="152">!MyTest1</td>
<td valign="top" width="448">Run all tests except for the method named MyTest1</td>
</tr>
<tr>
<td valign="top" width="152">MyTest1+MyTest2</td>
<td valign="top" width="448">Run the MyTest1 and MyTest2 test methods</td>
</tr>
</tbody>
</table>
<h3>Out of Browser support</h3>
<p>The framework now supports running out-of-browser. Paired with the new Silverlight 4 Tools for Visual Studio 2010, you can press F5 to run a test project you have marked as an out-of-browser.</p>
<p>This also opens up an opportunity to do testing of elevated apps that make use of AutomationFactory and other advanced features on Windows.</p>
<h3>Simplified dependencies</h3>
<p>The test framework removed dependencies on System.Windows.Browser (from the platform) and System.Xml.Linq (XLinq, from the SDK).</p>
<h3>Building blocks for Windows Phone testing support</h3>
<p>This version also contains the full source to the phone testing interface, which is significantly different in visual design and experience to coincide with the Windows Phone device size.</p>
<p>However, the story for phone testing is still developing: in the meantime binaries designed for phone use can be found at <a href="http://jeffatmix.com/">http://jeffatmix.com/</a> </p>
<h3>New location for binaries</h3>
<p>Since the new rich user interface contains a number of controls, the traditional design-time integration system conflicts and presents some issues.</p>
<p>As a result, we had to move the binaries from the Bin directory of the toolkit installation folder into a new Testing directory.</p>
<p>So the two test framework assemblies (Microsoft.Silverlight.Testing and Microsoft.VisualStudio.QualityTools.UnitTesting.Silverlight) have moved.</p>
<p>This location change could cause existing applications that reference the test assemblies to fail to compile due to the &quot;missing&quot; references.</p>
<p>If that happens, please delete the two broken references and create references to these assemblies in their new location. Everything else should continue to work as expected.</p>
<h3>Simplified test project template</h3>
<p>In alignment with the test project changes in Visual Studio 2010, which are more simplified, the unit test project template for Silverlight no longer includes a README.TXT file.</p>
<h3>Known issues</h3>
<h5>Test service</h5>
<p>I’ve received reports from a number of people about issues with the test service automation support. Some of the NDA/preview users of the framework reported issues that were corrected, but there may still be some bugs out there. I’m working to investigate and post a fix if and when I know more.</p>
<p>In the meantime I know that <a href="http://statlight.net/">StatLight</a>, a third party system, has been updated for the April release and is working well for automation.</p>
<h5>Test panel and visuals</h5>
<p>Please beware that some of your tests may need to be updated to use the new framework if your application, utility functions, or tests ever used the Application.Current.RootVisual (against the recommended pattern for interface testing).</p>
<p>The root visual is now the test framework application runner itself, and the tests run within the same TestPanel as before. Controls added to the test panel will not be located at the 0, 0 screen position, but likely near the bottom of the screen instead.</p>
<p>Hope this helps. To get started, download and install the April toolkit!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jeff.wilcox.name/2010/05/new-2010-test-framework/feed/</wfw:commentRss>
		<slash:comments>25</slash:comments>
		</item>
		<item>
		<title>&#8220;Peppermint&#8221; MIX demo sources</title>
		<link>http://www.jeff.wilcox.name/2010/03/peppermint-src/</link>
		<comments>http://www.jeff.wilcox.name/2010/03/peppermint-src/#comments</comments>
		<pubDate>Fri, 26 Mar 2010 21:30:53 +0000</pubDate>
		<dc:creator>Jeff Wilcox</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[MIX]]></category>
		<category><![CDATA[Testing]]></category>
		<category><![CDATA[Windows Phone]]></category>

		<guid isPermaLink="false">http://www.jeff.wilcox.name/2010/03/peppermint-src/</guid>
		<description><![CDATA[At MIX, during my talk on unit testing Silverlight and Windows Phone applications, I demoed a simple application called ‘Peppermint’. Here’s the source; I’ll be writing up a full tutorial on Windows Phone later, so these are just ‘bleeding-edge bits’. Peppermint-Demo.zip [Zip, 1.2 MB] Silverlight: Requires Visual Studio 2010 (or express) Requires the Silverlight Toolkit [...]]]></description>
			<content:encoded><![CDATA[<p>At MIX, during my talk on <a href="http://live.visitmix.com/MIX10/Sessions/CL59">unit testing Silverlight and Windows Phone applications</a>, I demoed a simple application called ‘Peppermint’. Here’s the source; I’ll be writing up a full tutorial on Windows Phone later, so these are just ‘bleeding-edge bits’.</p>
<p><a href="http://www.jeff.wilcox.name/wp-content/uploads/2010/03/Peppermint-Demo.zip"><strong>Peppermint-Demo.zip</strong></a> [Zip, 1.2 MB]</p>
<p>Silverlight:</p>
<blockquote><p>Requires Visual Studio 2010 (or express)     <br />Requires the <a href="http://silverlight.codeplex.com/">Silverlight Toolkit</a>      <br />Requires the test framework binaries included in the zip</p>
</blockquote>
<p>Windows Phone:</p>
<blockquote><p>Requires the <a href="http://www.silverlight.net/getstarted/devices/windows-phone/">Windows Phone development tools CTP</a>      <br />Requires the test framework binaries included in the zip</p>
</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.jeff.wilcox.name/2010/03/peppermint-src/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Unit Testing Silverlight &amp; Windows Phone Applications &#8211; talk now online</title>
		<link>http://www.jeff.wilcox.name/2010/03/mix10-testing-talk-online/</link>
		<comments>http://www.jeff.wilcox.name/2010/03/mix10-testing-talk-online/#comments</comments>
		<pubDate>Wed, 17 Mar 2010 22:07:26 +0000</pubDate>
		<dc:creator>Jeff Wilcox</dc:creator>
				<category><![CDATA[MIX]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Silverlight Toolkit]]></category>
		<category><![CDATA[Testing]]></category>
		<category><![CDATA[Windows Phone]]></category>

		<guid isPermaLink="false">http://www.jeff.wilcox.name/2010/03/mix10-testing-talk-online/</guid>
		<description><![CDATA[My MIX 10 talk, an introduction to unit testing on Silverlight and the Windows Phone, is now online for streaming and download. Thank you to everyone who attended. An early preview set of bits are online at http://jeffatmix.com/ – and the next release of the Silverlight Toolkit when Silverlight 4 ships will contain support for [...]]]></description>
			<content:encoded><![CDATA[<p>My <a href="http://live.visitmix.com/MIX10/Sessions/CL59">MIX 10 talk</a>, an introduction to unit testing on Silverlight and the Windows Phone, <a href="http://live.visitmix.com/MIX10/Sessions/CL59">is now online</a> for streaming and download. Thank you to everyone who attended.</p>
<p>An early preview set of bits are online at <a href="http://jeffatmix.com/">http://jeffatmix.com/</a> – and the next release of the Silverlight Toolkit when Silverlight 4 ships will contain support for the phone officially. Stay tuned for more.</p>
<p><a href="http://www.jeff.wilcox.name/2010/03/mix10-testing-talk-online/"><img style="border-bottom: 0px; border-left: 0px; display: inline; margin-left: 0px; border-top: 0px; margin-right: 0px; border-right: 0px" title="SilverlightUnitTestFrameworkforWindowsPhone[1]" border="0" alt="SilverlightUnitTestFrameworkforWindowsPhone[1]" src="http://www.jeff.wilcox.name/wp-content/uploads/2010/03/SilverlightUnitTestFrameworkforWindowsPhone1_thumb.jpg" width="360" height="480" /></a> </p>
<p>Over the next few weeks, I’ll be blogging plenty on these subjects.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jeff.wilcox.name/2010/03/mix10-testing-talk-online/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Ready to test those Silverlight and Windows Phone 7 Series apps?</title>
		<link>http://www.jeff.wilcox.name/2010/03/mix10-cl59-intro/</link>
		<comments>http://www.jeff.wilcox.name/2010/03/mix10-cl59-intro/#comments</comments>
		<pubDate>Mon, 08 Mar 2010 02:54:33 +0000</pubDate>
		<dc:creator>Jeff Wilcox</dc:creator>
				<category><![CDATA[Conferences]]></category>
		<category><![CDATA[MIX]]></category>
		<category><![CDATA[Presentations]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Silverlight Toolkit]]></category>
		<category><![CDATA[Testing]]></category>
		<category><![CDATA[Windows Phone]]></category>

		<guid isPermaLink="false">http://www.jeff.wilcox.name/2010/03/mix10-cl59-intro/</guid>
		<description><![CDATA[At MIX 10 this year, Tues. 3/16 at 2pm: Learn from Jeff Wilcox how to create and maintain Silverlight and Windows Phone 7 Series applications using the Silverlight Unit Test Framework.]]></description>
			<content:encoded><![CDATA[<p><img style="border-bottom: 0px; border-left: 0px; display: inline; margin-left: 0px; border-top: 0px; margin-right: 0px; border-right: 0px" title="Mix10_LoveTheWeb_blk_240" border="0" alt="Mix10_LoveTheWeb_blk_240" align="right" src="http://www.jeff.wilcox.name/wp-content/uploads/2010/03/Mix10_LoveTheWeb_blk_240.jpg" width="240" height="320" /> That’s right, my MIX 10 session’s been announced! Come learn about testing those apps.</p>
<p><a href="http://live.visitmix.com/MIX10/Sessions/CL59"><strong>UNIT TESTING SILVERLIGHT AND WINDOWS PHONE APPLICATIONS</strong></a>    <br />Jeff Wilcox in Lagoon B (Mandalay Bay)    <br />Tuesday, March 16, 2010 2:05 PM (30 minutes)</p>
<p>Session materials, slides and code will be posted after the session at <a href="http://jeffatmix.com/">http://jeffatmix.com/</a>.</p>
<p>Synposis from <a href="http://live.visitmix.com/MIX10/Sessions/CL59">http://live.visitmix.com/MIX10/Sessions/CL59</a>:</p>
<blockquote><p>Learn how to create and maintain Silverlight and Windows Phone 7 Series applications using the Silverlight Unit Test Framework. See what tools are available to easily validate controls and application interfaces, add automatic testing to builds, and gain a solid understanding of test principles to deliver great experiences for your clients and customers.</p>
</blockquote>
<p><em>What’ll be new at MIX for testing?</em></p>
<ul>
<li>Support for testing those Windows Phone 7 Series apps!</li>
<li>New release of the Silverlight Unit Test Framework, with a modern user interface, Out of Browser support, and more.</li>
</ul>
<p>Hope to see you all in Vegas! And if not – these sessions always make it online super quick. Let me know if there’s anything in particular you want covered in the talk.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jeff.wilcox.name/2010/03/mix10-cl59-intro/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Walkthrough: The power of the November 2009 Silverlight Toolkit testing tools</title>
		<link>http://www.jeff.wilcox.name/2009/11/november-walkthrough/</link>
		<comments>http://www.jeff.wilcox.name/2009/11/november-walkthrough/#comments</comments>
		<pubDate>Fri, 20 Nov 2009 23:02:09 +0000</pubDate>
		<dc:creator>Jeff Wilcox</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Infrastructure]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Silverlight Toolkit]]></category>
		<category><![CDATA[Testing]]></category>

		<guid isPermaLink="false">http://www.jeff.wilcox.name/2009/11/november-walkthrough/</guid>
		<description><![CDATA[The November 2009 Silverlight Toolkit is essentially a tools and infrastructure release on top of the October 2009 release (where we first introduced Visual Studio 2010 support). It also adds a Silverlight 4 Beta version. New infrastructure &#38; test tools ship in the Silverlight Toolkit There is a lot in the release that is joining [...]]]></description>
			<content:encoded><![CDATA[<p>The November 2009 Silverlight Toolkit is essentially a tools and infrastructure release on top of the October 2009 release (where we first introduced Visual Studio 2010 support). It also adds a Silverlight 4 Beta version.</p>
<h2>New infrastructure &amp; test tools ship in the Silverlight Toolkit</h2>
<p>There is a lot in the release that is joining publicly for the first time, based on some of the internal tools and utilities that we use in building and testing the Silverlight Toolkit, plus things we’d like to have as typical Silverlight developers.</p>
<p>These tools join in the Experimental quality band, and over the next few posts, I’ll dig into the details. This post is a literal walkthrough of how you could go about seeing all the utilities in the meantime.</p>
<p>One important thing to call out is that, as an initial release, there are definitely some rough edges: the test tools are centered around Microsoft Build (msbuild) integration, instead of Visual Studio integration; there’s no add-in or nice right-click project support to use these tools today.</p>
<p>We’ll be collecting feedback along the way and making changes in future releases. Until then, hopefully some of you will find the infrastructure useful, if only to peak behind the curtain. We’re also shipping the full source to these tools, you’ll find an Infrastructure.zip file inside the toolkit install folder.</p>
<h4>What we’ll do in this walkthrough</h4>
<p>This walkthrough uses Silverlight 4, though the instructions are virtually identical if you’re using Silverlight 3.</p>
<ul>
<li>Install the Silverlight Toolkit</li>
<li>Create a new Silverlight class library with a simple business object</li>
<li>Add a Silverlight Unit Test Application using the new templates found in the Silverlight Toolkit</li>
<li>Run the tests in Visual Studio</li>
<li>Run the tests from the command line in various browsers</li>
<li>Collect block-level code coverage information for the build</li>
</ul>
<p>This is screen-shot heavy, as future posts will dig into the details. I appreciate your patience!</p>
<p>Requirements:</p>
<ul>
<li>Latest Silverlight Toolkit</li>
<li>For test automation:</li>
</ul>
<ul>
<li>MSBuild on the machine</li>
</ul>
<li>For code coverage:</li>
<ul>
<li>Visual Studio 2010 Beta 2 Ultimate</li>
</ul>
<h2>Installing the tools</h2>
<p>When you install either Silverlight Toolkit drop from November, you’ll see that there’s a new feature listed in the setup: the Tools &amp; Templates feature. It’s selected by default, and adds Visual Studio templates, installs the tools, and prepares the tools if your machine has the proper dependencies on it.</p>
<p><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="SetupNewFeature" border="0" alt="SetupNewFeature" src="http://www.jeff.wilcox.name/wp-content/uploads/2009/11/SetupNewFeature.png" width="541" height="430" /> </p>
<h2>Create a Silverlight Class Library</h2>
<p>Open Visual Studio 2010 Beta 2, after installing the toolkit. Create a new <strong>Silverlight Class Library</strong> project, we’ll store a simple business object in it.</p>
<p><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="VisualStudioNewSilverlightClassLibraryProject" border="0" alt="VisualStudioNewSilverlightClassLibraryProject" src="http://www.jeff.wilcox.name/wp-content/uploads/2009/11/VisualStudioNewSilverlightClassLibraryProject.png" width="685" height="480" /> </p>
<p>Whichever flavor of Silverlight you use, remember to use the same flavor while creating future projects in the same solution!</p>
<p><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="VisualStudioSelectSilverlightVersion" border="0" alt="VisualStudioSelectSilverlightVersion" src="http://www.jeff.wilcox.name/wp-content/uploads/2009/11/VisualStudioSelectSilverlightVersion.png" width="685" height="231" /></p>
<p>Create a new Person.cs type, with a few properties and a method. Here’s the source:</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:887EC618-8FBE-49a5-A908-2339AF2EC720:bc34624e-1aaa-4618-a4cc-6c9dad4c3107" class="wlWriterEditableSmartContent">
<pre class="c-sharp" name="code">using System;

namespace MyApplication
{
    public class Person
    {
        public string First { get; set; }
        public string Last { get; set; }

        public string FullName { get { return First + " " + Last; } }

        public bool MightBe(string substring)
        {
            return FullName.Contains(substring);
        }
    }
}</pre>
</div>
<h2>Add a Silverlight Unit Test Application</h2>
<p>Right-click on the solution in the Solution Explorer and select Add New Project. Under the Visual C# (and also Visual Basic) languages node, select the Silverlight subgroup. You’ll see a <strong>Silverlight Unit Test Application</strong> project template.</p>
<p><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="VisualStudioUnitTestTemplate" border="0" alt="VisualStudioUnitTestTemplate" src="http://www.jeff.wilcox.name/wp-content/uploads/2009/11/VisualStudioUnitTestTemplate.png" width="685" height="446" /></p>
<p>You now have two projects:</p>
<p><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="VisualStudioTestAppAndClassLibrarySolutionExplorer" border="0" alt="VisualStudioTestAppAndClassLibrarySolutionExplorer" src="http://www.jeff.wilcox.name/wp-content/uploads/2009/11/VisualStudioTestAppAndClassLibrarySolutionExplorer.png" width="283" height="385" /></p>
<p>Next up, we want to add a reference to the class library, so that the unit tests can access the library. Right-click on the new test project and then select the Add Reference option. Under the Project tab, choose the class library you created earlier.</p>
<p><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="VisualStudioAddReference" border="0" alt="VisualStudioAddReference" src="http://www.jeff.wilcox.name/wp-content/uploads/2009/11/VisualStudioAddReference.png" width="593" height="478" /></p>
<p>Now, let’s add some unit tests. Clear out the content in the created Tests.cs file and drop this in:</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:887EC618-8FBE-49a5-A908-2339AF2EC720:a7e8d8fd-b4cb-4725-bb1a-cd35db6190c2" class="wlWriterEditableSmartContent">
<pre class="c-sharp" name="code">using Microsoft.VisualStudio.TestTools.UnitTesting;
using MyApplication;

namespace PersonTestProject {
    [TestClass]
    public class Tests
    {
        [TestMethod]
        public void TestCtor()
        {
            Person p = new Person();
        }

        [TestMethod]
        public void TestSetName()
        {
            Person p = new Person { First = "Scott", Last = "Guthrie" };
            Assert.AreNotEqual(p.First, p.Last);
        }

        [TestMethod]
        public void TestGetFullName()
        {
            Person p = new Person { First = "Steve", Last = "Ballmer" };
            StringAssert.Equals("Steve Ballmer", p.FullName);
        }
    }
}</pre>
</div>
<p>The tests are pretty simple, and exercise various simple PMEs on the type.</p>
<h2>Run the unit tests from Visual Studio</h2>
<p>Right-click on the test project and select Set as StartUp Project from the menu. Then, press F5 or click the Run button to begin execution.</p>
<p><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="VisualStudioSetAsStartupProject" border="0" alt="VisualStudioSetAsStartupProject" src="http://www.jeff.wilcox.name/wp-content/uploads/2009/11/VisualStudioSetAsStartupProject.png" width="530" height="605" /> </p>
<p> The default web browser will open up, the tests will run, and the window will stay open. When you are satisfied, close the browser. You’ve just run some simple tests!</p>
<h2>Running unit tests from the Visual Studio command line</h2>
<p>More interesting is being able to automate the tests: through MSBuild, we’ve added a task that can control the browser and save out the log file(s) from the unit tests when they run.</p>
<p>To do this, you need a few things:</p>
<ul>
<li>The Visual Studio command prompt open.</li>
<li>The full path to the test project.</li>
</ul>
<h4>Open the command prompt</h4>
<p>Personally, I always pin the Visual Studio 2008 tools command prompt next to my Visual Studio taskbar icons.</p>
<p><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="TaskbarCmdPrompt" border="0" alt="TaskbarCmdPrompt" src="http://www.jeff.wilcox.name/wp-content/uploads/2009/11/TaskbarCmdPrompt.png" width="685" height="71" /> </p>
<p>You can start it from the Start Menu, under the tools for the Visual Studio version you are using.</p>
<p>Alternatively, make sure MSBuild is in your path.</p>
<p>Or, start a command prompt and then move to your 32-bit Program Files, then ‘Visual Studio 9.0’, then VC. Run ‘vcvarsall.bat x86’</p>
<p><strong>Note</strong>: all these command prompts should be 32-bit, even on a x64 machine. Silverlight is a 32-bit world today.</p>
<h4>Move to the test project</h4>
<p>To get the full path to the test project, I just right-click on the test project in Visual Studio, then Open Folder in Windows Explorer. I copy the path from the resulting Explorer dialog’s crumb navigation bar.</p>
<p><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="VisualStudioOpenWindowsExplorerForProjectLocation" border="0" alt="VisualStudioOpenWindowsExplorerForProjectLocation" src="http://www.jeff.wilcox.name/wp-content/uploads/2009/11/VisualStudioOpenWindowsExplorerForProjectLocation.png" width="685" height="428" /> </p>
<p>Now, inside the command prompt window, move to that path:</p>
<blockquote>
<p>pushd (PASTE PATH HERE) &lt;enter&gt;</p>
</blockquote>
<p>To run the unit tests in the default browser, simply type </p>
<blockquote>
<p><strong>msbuild /t:test</strong> </p>
</blockquote>
<p>and press Enter.</p>
<p><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="CommandLineMsbuildTest" border="0" alt="CommandLineMsbuildTest" src="http://www.jeff.wilcox.name/wp-content/uploads/2009/11/CommandLineMsbuildTest.png" width="685" height="120" /></p>
<p>You’ll see the browser open, quickly run some tests, and then close. Here’s what it looks like, captured in the middle of the 5-second test run:</p>
<p><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="TestRunningInInternetExplorer" border="0" alt="TestRunningInInternetExplorer" src="http://www.jeff.wilcox.name/wp-content/uploads/2009/11/TestRunningInInternetExplorer.png" width="685" height="345" /></p>
<p>And afterwards, you’ll see that Msbuild reports success, and you can read the test to see that 3 passing tests were reported, out of 3 total tests.</p>
<p><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="CommandLineMsbuildTestWithResults" border="0" alt="CommandLineMsbuildTestWithResults" src="http://www.jeff.wilcox.name/wp-content/uploads/2009/11/CommandLineMsbuildTestWithResults.png" width="685" height="433" /></p>
<h3>Running tests in Google Chrome</h3>
<p>It’s easy! Just set the browser property to Chrome.</p>
<blockquote>
<p><strong><font color="#808080">msbuild /t:test </font>/p:browser=chrome</strong></p>
</blockquote>
<p><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="CommandLineMsbuildTestChrome" border="0" alt="CommandLineMsbuildTestChrome" src="http://www.jeff.wilcox.name/wp-content/uploads/2009/11/CommandLineMsbuildTestChrome.png" width="685" height="67" />&#160;</p>
<p>And just like that, Chrome opens up and runs the tests.</p>
<p><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="TestRunningInChrome" border="0" alt="TestRunningInChrome" src="http://www.jeff.wilcox.name/wp-content/uploads/2009/11/TestRunningInChrome.png" width="685" height="428" /></p>
<h3>Running tests in Mozilla Firefox</h3>
<p>Just set the browser to Firefox.</p>
<blockquote>
<p><strong><font color="#808080">msbuild /t:test </font>/p:browser=firefox</strong></p>
</blockquote>
<p><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="TestRunningInFirefox" border="0" alt="TestRunningInFirefox" src="http://www.jeff.wilcox.name/wp-content/uploads/2009/11/TestRunningInFirefox.png" width="685" height="428" /></p>
<h3>Tag Expressions</h3>
<p>A nice feature to help select a subset of tests is the Tag Expression syntax. By specifying a tag expression at the command prompt, you can include and exclude tests that are marked with the Tag attribute found in Microsoft.Silverlight.Testing.</p>
<p>Also, tags <strong>implicitly exist for all test method names,</strong> short and full.</p>
<p>So, let’s run the test called <strong>TestSetName</strong> from our project.</p>
<blockquote>
<p><strong><font color="#808080">msbuild /t:test </font>/p:tagexpression=TestSetName</strong></p>
</blockquote>
<p>You may briefly see indication in the test UI in the browser that a ‘Tag expression’ is in use.</p>
<p><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="TestRunningInInternetExplorerWithTagExpression" border="0" alt="TestRunningInInternetExplorerWithTagExpression" src="http://www.jeff.wilcox.name/wp-content/uploads/2009/11/TestRunningInInternetExplorerWithTagExpression.png" width="685" height="344" /></p>
<p>And the build results show that just one test ran:</p>
<p>&#160;<img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="CommandLineMsbuildTestWithTagExpressionResults" border="0" alt="CommandLineMsbuildTestWithTagExpressionResults" src="http://www.jeff.wilcox.name/wp-content/uploads/2009/11/CommandLineMsbuildTestWithTagExpressionResults.png" width="685" height="433" /> </p>
<p>If you want to run all tests <strong>except that one</strong>, use this tag expression:</p>
<blockquote>
<p><strong><font color="#808080">msbuild /t:test </font>/p:tagexpression=!TestSetName</strong></p>
</blockquote>
<p>Cool, and easy!</p>
<h3>Test results files</h3>
<p>Another nice feature of running the tests through MSBuild is that you’ll see test result files (end in *.trx) inside the same folder as the test page for the application.</p>
<p>Similar and conformant to the Visual Studio *.trx format, you can parse and work with this data to understand execution times, results, and read other information. Unfortunately, you cannot open these files in Visual Studio 2010 Beta 2, but they do open in Visual Studio 2008. Note that there isn’t any real test integration with VS here: this is just an informative display. </p>
<p>Here’s a directory with several test result files (plus some coverage stuff we’ll get to later):</p>
<p><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="LookingInTheBinariesFolderAfterTestsRun" border="0" alt="LookingInTheBinariesFolderAfterTestsRun" src="http://www.jeff.wilcox.name/wp-content/uploads/2009/11/LookingInTheBinariesFolderAfterTestsRun.png" width="685" height="502" /></p>
<p>You can open up the TestResults trx file and see what kind of information is in it:</p>
<p><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="LookingAtTheTrxFile" border="0" alt="LookingAtTheTrxFile" src="http://www.jeff.wilcox.name/wp-content/uploads/2009/11/LookingAtTheTrxFile.png" width="685" height="524" /></p>
<p>And here’s the results file opened in Visual Studio:</p>
<p><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="VisualStudio2008TestResultsTrxFile" border="0" alt="VisualStudio2008TestResultsTrxFile" src="http://www.jeff.wilcox.name/wp-content/uploads/2009/11/VisualStudio2008TestResultsTrxFile.png" width="685" height="312" />&#160;</p>
<h2>Preparing for Code Coverage</h2>
<p>Ripe for a Visual Studio add-in, this process requires us modifying the test project’s .csproj file some. Instructions are the same for Visual Studio.</p>
<p>We need to <strong>manually select the assembly to be instrumented </strong>by setting a property. The assembly to be instrumented must not be signed, and not have a strong name. In this example, the assembly is <strong>SilverlightClassLibrary3</strong>.</p>
<p>To make changes to the test project, to specify this, first unload the project by right-clicking on the test project and selecting the Unload option: </p>
<p><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="VisualStudioUnloadProject" border="0" alt="VisualStudioUnloadProject" src="http://www.jeff.wilcox.name/wp-content/uploads/2009/11/VisualStudioUnloadProject.png" width="503" height="621" /></p>
<p>Then, right-click the project file that is ‘(unavailable) and select ‘Edit’. </p>
<p><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="VisualStudioEditProject" border="0" alt="VisualStudioEditProject" src="http://www.jeff.wilcox.name/wp-content/uploads/2009/11/VisualStudioEditProject.png" width="492" height="214" /></p>
<p>Now you’ll see the XML data for the project. Scroll down in the template to where there is a commented out ItemGroup, and some comments about the code coverage support. Remove the comments from the ItemGroup: </p>
<p><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="VisualStudioEditingTestProjectFileOriginal" border="0" alt="VisualStudioEditingTestProjectFileOriginal" src="http://www.jeff.wilcox.name/wp-content/uploads/2009/11/VisualStudioEditingTestProjectFileOriginal.png" width="685" height="435" /></p>
<p>And now, change the Include statement from SilverlightClassLibrary1 to whatever your assembly to instrument is called. In our example here, it is called SilverlightClassLibrary3.</p>
<p>&#160;<img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="VisualStudioEditingTestProjectFile2" border="0" alt="VisualStudioEditingTestProjectFile2" src="http://www.jeff.wilcox.name/wp-content/uploads/2009/11/VisualStudioEditingTestProjectFile2.png" width="685" height="435" /> </p>
<p> Now, that’s it. Let’s close the file and then right-click the project again and select Reload Project:</p>
<p>&#160;<img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="VisualStudioReloadTestProject" border="0" alt="VisualStudioReloadTestProject" src="http://www.jeff.wilcox.name/wp-content/uploads/2009/11/VisualStudioReloadTestProject.png" width="502" height="400" /> </p>
<p> Now we’re ready to go!</p>
<h2>Running Silverlight Code Coverage</h2>
<p>Just like the msbuild /t:test from above, we have a similar target named <strong>CoverageTest</strong> and <strong>CoverageView</strong>. CoverageTest collects the data, while CoverageView collects the coverage data and then shows the results in an application that explores the hit and not hit portions of your source code.</p>
<p>Let’s collect coverage!</p>
<p><strong>Note:</strong> This is assuming that you have a high-level SKU of Visual Studio 2010 Beta 2 installed. The coverage tools depend on the Static Analysis Tools that ship in the beta. You will receive an error if you run this on a machine without those tools. We’ll look for a better experience in the future.</p>
<p>Remember, the same properties from above – browser and tag expression – still can apply and work in the coverage targets.</p>
<blockquote>
<p><strong><font color="#808080">msbuild </font>/t:coveragetest</strong></p>
</blockquote>
<p>Here is what it will look like if everything line up. Unfortunately, the coverage experience is a very early preview and very flaky in some situations due to the dependency on beta components. We also haven’t had I admit enough time to iron out all the issues customers may experience.</p>
<p>You see the Instrumentation messages come out, then the RunTests target, then the coverage data is merged and things should be successful. </p>
<p>&#160;<img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="CommandLineMsbuildCoverageTestResults" border="0" alt="CommandLineMsbuildCoverageTestResults" src="http://www.jeff.wilcox.name/wp-content/uploads/2009/11/CommandLineMsbuildCoverageTestResults.png" width="685" height="433" /></p>
<p>If that worked, it is safe to assume that the view target will also work. It will re-run all the tests and instrument again as well.</p>
<blockquote>
<p><strong><font color="#808080">msbuild </font>/t:coverageview</strong></p>
</blockquote>
<p>Now you’ll see the viewer popup, that lets you drill into types and methods to see what is hit (cyan) or not hit (red), to spot code that your tests are missing:</p>
<h3><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="LookingAtCodeCoverage" border="0" alt="LookingAtCodeCoverage" src="http://www.jeff.wilcox.name/wp-content/uploads/2009/11/LookingAtCodeCoverage.png" width="685" height="428" /></h3>
<p>You’ll find a Coverage.xml file in the same directory where the test results go. This is the data that is used by the viewer application. You’ll see in the XML file a set of ‘visited’ blocks, and other information, in the file:</p>
<p><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="CoverageXmlFile" border="0" alt="CoverageXmlFile" src="http://www.jeff.wilcox.name/wp-content/uploads/2009/11/CoverageXmlFile.png" width="685" height="435" /> </p>
<p>More to come soon!</p>
<h3>Download the Silverlight Toolkit November 2009 Release Today</h3>
<p><a href="http://silverlight.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=36060"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Toolkit32[2][2][2]" border="0" alt="Toolkit32[2][2][2]" src="http://www.jeff.wilcox.name/wp-content/uploads/2009/11/Toolkit32222.png" width="685" height="88" /></a> </p>
<p>The Silverlight Toolkit is a collection of Silverlight controls, components and utilities that help make Silverlight development a little easier, more fun, and add value outside the regular Silverlight release cycle.</p>
<p>The sixth release of the Silverlight Toolkit, the November 2009 release targets Silverlight 3. There is also a release available that targets the new Silverlight 4 Beta for developers.</p>
<p>Resources of note:</p>
<ul>
<li><a href="http://silverlight.codeplex.com/">Learn more about the Silverlight Toolkit</a> </li>
<li><a href="http://silverlight.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=36060"><strong>Download the November 2009 Release</strong></a> </li>
<li><a href="http://silverlight.net/getstarted/">Get started with Silverlight development</a> </li>
<li>Participate in the <a href="http://silverlight.net/forums/35.aspx">controls community at Silverlight.net</a> </li>
<li>Check out questions and answers on Stack Overflow using the <a href="http://stackoverflow.com/questions/tagged/silverlight-toolkit">‘silverlight-toolkit’ tag</a> </li>
<li>The <a href="http://silverlight.codeplex.com/WorkItem/List.aspx">Issue Tracker</a> can be used to report issues, add to the feature wish list, and vote on the work to be done by the Microsoft team </li>
</ul>
<p><em>Hope you enjoy our new release!</em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.jeff.wilcox.name/2009/11/november-walkthrough/feed/</wfw:commentRss>
		<slash:comments>45</slash:comments>
		</item>
		<item>
		<title>Silverlight 3 unit test framework binaries available</title>
		<link>http://www.jeff.wilcox.name/2009/07/silverlight-3-unit-test-framework-binaries-available/</link>
		<comments>http://www.jeff.wilcox.name/2009/07/silverlight-3-unit-test-framework-binaries-available/#comments</comments>
		<pubDate>Fri, 17 Jul 2009 05:42:24 +0000</pubDate>
		<dc:creator>Jeff Wilcox</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Silverlight Toolkit]]></category>
		<category><![CDATA[Testing]]></category>

		<guid isPermaLink="false">http://www.jeff.wilcox.name/?p=433</guid>
		<description><![CDATA[Two weeks ago, I posted the July 2009 release of the Silverlight Unit Test Framework online for folks looking for updated bits. Of course, the real gem is the Silverlight 3 version. Now that Silverlight 3 has shipped, you should definitely look at moving forward to this great new version. Download the binaries I’ve updated [...]]]></description>
			<content:encoded><![CDATA[<p>Two weeks ago, I posted the July 2009 release of the <a href="http://code.msdn.microsoft.com/silverlightut">Silverlight Unit Test Framework</a> online for folks looking for updated bits. Of course, the real gem is the Silverlight 3 version. Now that <a href="http://www.silverlight.net/">Silverlight 3</a> has shipped, you should definitely look at moving forward to this great new version.</p>
<h3>Download the binaries</h3>
<p>I’ve updated the MSDN code site for the product with the Silverlight 3-specific binaries, for anyone that is interested.</p>
<p>103K, Zip: <a href="http://code.msdn.microsoft.com/Project/Download/FileDownload.aspx?ProjectName=silverlightut&amp;DownloadId=6603">Direct link</a><br /><a href="http://code.msdn.microsoft.com/silverlightut">MSDN Code Gallery web site for the framework</a></p>
<h3>Find the binaries in the Silverlight Toolkit</h3>
<p>If you’re using the <a href="http://silverlight.codeplex.com/">Silverlight Toolkit</a> July 2009 release for Silverlight 3, you’ve already got the Silverlight unit test framework binaries on your machine. They’re located in the source code package (Source code.zip).</p>
<p>Here’s how to track them down…</p>
<h4>When installing the Silverlight Toolkit</h4>
<p>Make sure that you keep the &#8220;Source Code&#8221; feature of the Silverlight Toolkit checked. That will place the zip package on your system with the source, plus the unit test framework binaries.<br />
<img alt="" src="http://media.jeff.wilcox.name/blog/view/InstallToolkit1.png" class="alignnone" width="685" height="444" />
</p>
<h4>Locate the source code for the toolkit</h4>
<p>Go ahead and find the zip package after installation, and extract it to your system somewhere.<br />
<img alt="" src="http://media.jeff.wilcox.name/blog/view/InstallToolkit2.png" class="alignnone" width="685" height="149" />
</p>
<h4>Jump into the Binaries folder of the extracted package</h4>
<p><img alt="" src="http://media.jeff.wilcox.name/blog/view/InstallToolkit3.png" class="alignnone" width="658" height="160" /></p>
<h4>Use the Silverlight unit test framework</h4>
<p>And now you’re good to go. You’ll find the binaries in that folder, and you should add references to both Microsoft.Silverlight.Testing and then the unit test metadata assembly, Microsoft.VisualStudio.QualityTools.UnitTesting.Silverlight.dll</p>
<h3>What’s new in the July 2009 bits of the Silverlight Unit Test Framework?</h3>
<ul>
<li>Support for the [Timeout(...)] attribute on test methods. </li>
<li>Improvements to the Test Service interface. The service now has an asynchronous reporting phase that allows for more robust automation options (details coming soon). </li>
<li>Minor interface changes </li>
<li>Minor bug fixes</li>
</ul>
<h3>No fundamental differences between the Silverlight 2 and 3 versions</h3>
<p>There are no fundamental differences between the versions, and the Silverlight 2 version of the framework works fine with Silverlight 3 application development. But it makes sense to use the appropriate version.</p>
<p>Looking forward, we may move the unit test framework right into the <a href="http://silverlight.codeplex.com/">Silverlight Toolkit</a>, for ease of use.</p>
<p>Hope this helps!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jeff.wilcox.name/2009/07/silverlight-3-unit-test-framework-binaries-available/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Python and Ruby, Silverlight, and testing</title>
		<link>http://www.jeff.wilcox.name/2009/07/dlr-test-links/</link>
		<comments>http://www.jeff.wilcox.name/2009/07/dlr-test-links/#comments</comments>
		<pubDate>Wed, 08 Jul 2009 18:54:42 +0000</pubDate>
		<dc:creator>Jeff Wilcox</dc:creator>
				<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Testing]]></category>

		<guid isPermaLink="false">http://www.jeff.wilcox.name/?p=431</guid>
		<description><![CDATA[Here are two nice posts by Jimmy Schementi, one showing simple testing in Python, the other using IronRuby to actually test C# apps!]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve neglected the dynamic languages crowd, more or less, but recently came across a few nice posts by Jimmy Schementi that are a great start to getting the DLR folks testing. It&#8217;s quite easy to get going!</p>
<ul>
<li><a href="http://blog.jimmy.schementi.com/2009/06/simple-python-testing-in-silverlight.html">Simple Python unit testing</a></li>
<li>Super awesome &#8211; <a href="http://blog.jimmy.schementi.com/2009/03/testing-c-silverlight-apps-with.html">Testing a C# app using IronRuby</a></li>
</ul>
<p>If there&#8217;s anything else nice out there in the wild, let me know! <em>Note that these don&#8217;t use the Silverlight unit test framework, but rather some nice dynamic language test goods.</em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.jeff.wilcox.name/2009/07/dlr-test-links/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Three great screencasts on Silverlight unit testing</title>
		<link>http://www.jeff.wilcox.name/2009/07/three-great-screencasts-on-silverlight-unit-testing/</link>
		<comments>http://www.jeff.wilcox.name/2009/07/three-great-screencasts-on-silverlight-unit-testing/#comments</comments>
		<pubDate>Thu, 02 Jul 2009 07:36:07 +0000</pubDate>
		<dc:creator>Jeff Wilcox</dc:creator>
				<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Testing]]></category>
		<category><![CDATA[Video]]></category>

		<guid isPermaLink="false">http://www.jeff.wilcox.name/?p=428</guid>
		<description><![CDATA[If you're looking to learn more about Silverlight unit testing, here are 3 screencasts of interest.]]></description>
			<content:encoded><![CDATA[<p>I just wanted to pass along a few links to developers interested in learning more about Silverlight unit testing through video. Eric Litovsky (<a href="http://zenthought.com/">http://zenthought.com/</a>) recently published these guides.</p>
<ul>
<li><a href="http://zenthought.com/archive/2009/06/22/test-driven-development-for-silverlight-3-introduction.aspx">Test Driven Development for Silverlight &#8211; Introduction</a></li>
<li><a href="http://zenthought.com/archive/2009/06/22/test-driven-development-for-silverlight-3-unit-testing.aspx">Part 2 &#8211; covers a navigation application</a></li>
<li><a href="http://zenthought.com/archive/2009/06/22/test-driven-development-for-silverlight-3-integration-testing.aspx">Part 3 &#8211; jumps into integration testing</a> (more than just unit testing)</li>
</ul>
<p>It&#8217;s great seeing the community getting involved in expanding knowledge and the references out there. Thanks Eric!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jeff.wilcox.name/2009/07/three-great-screencasts-on-silverlight-unit-testing/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Asynchronous test support &#8211; Silverlight unit test framework and the UI thread</title>
		<link>http://www.jeff.wilcox.name/2009/03/asynchronous-testing/</link>
		<comments>http://www.jeff.wilcox.name/2009/03/asynchronous-testing/#comments</comments>
		<pubDate>Wed, 04 Mar 2009 08:14:22 +0000</pubDate>
		<dc:creator>Jeff Wilcox</dc:creator>
				<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Testing]]></category>

		<guid isPermaLink="false">http://www.jeff.wilcox.name/2009/03/asynchronous-testing/</guid>
		<description><![CDATA[A discussion about the asynchronous, on-the-UI thread test features and methods found in the Silverlight unit test framework, along with some history.]]></description>
			<content:encoded><![CDATA[<p>The Silverlight unit test framework has built-in functionality for some unique situations that pop up when you are testing key applications and components on the Silverlight platform. In fact, the entire framework has been built around the idea of performing a majority of the unit testing on the <strong>user interface thread</strong>, right inside the browser, as a Silverlight application itself.</p>
<p>This is a discussion, and a great whiteboard exercise, that I’ve had with many folks. I figure, it is finally time for me to at least blog a little bit about it. For the history behind this decision, see the bottom of this post.</p>
<p>As usual, you’ll find the unit test framework binaries and sample tests in the <a href="http://www.codeplex.com/Silverlight/">Silverlight Toolkit</a> download. Other posts by me on this topic can be <a href="http://www.jeff.wilcox.name/topics/dev/testing/">found here</a>.</p>
<p>If you use the asynchronous work item functionality in the test framework, do realize that your tests will no longer be subset compatible with the full desktop Visual Studio unit test framework.</p>
<h3>What’s happening during a unit test run</h3>
<p>The unit tests that run in the browser need to leave time for the browser, the native Silverlight plugin, the .NET CLR, and other components to do work between calls. This means that much of the execution is driven forward using dispatchers.</p>
<p>If you compare a typical test run on Silverlight to one in a desktop unit test framework, and compare how they run over time, you get this:</p>
<p><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="Comparing Silverlight and desktop unit test framework execution" border="0" alt="Comparing Silverlight and desktop unit test framework execution" src="http://media.jeff.wilcox.name/blog/view/ComparingExecution.png" width="685" height="631" /> </p>
<p>So, you get this interesting stack:</p>
<ul>
<li>Browser is rendering, calls into</li>
<li>Native Silverlight plugin</li>
<li>.NET runtime</li>
<li>Silverlight test application</li>
<li>Silverlight unit test harness, test assembly, class, and method management types</li>
<li><em>Your test method</em></li>
</ul>
<p>If you want to test the DOM being updated by a test, for instance, in the real browser (not mocked), you have to effectively let the call stack unwind enough for the browser to update the DOM… then let the test framework eventually jump back into action to process the remainder of the test.</p>
<h3>What happens when an [Asynchronous] test executes</h3>
<p>The AsynchronousAttribute from the Microsoft.Silverlight.Testing namespace, and in the assembly of the same name, tells the test framework:</p>
<blockquote>
<p>Hello! I’m going to do some stuff now. And when this method returns, well, I’m going to continue doing work. So don’t report any results yet… </p>
<p>… In fact, wait for me to send you a ‘test complete’ message – or throw an unhandled exception – to make a call, OK?</p>
</blockquote>
<p>This means that the entire methods executes, and then any queued up work items are run <em>afterwards</em>, each in due time. Here’s a way to compare a standard (single invoke) test to an asynchronous test:</p>
<p><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="Comparing asynchronous test runs" border="0" alt="Comparing asynchronous test runs" src="http://media.jeff.wilcox.name/blog/view/ComparingAsyncTestRun.png" width="685" height="421" /> </p>
<p>Asynchronous in this test framework’s context means that additional work is queued up – NOT that it happens immediately on a separate thread.</p>
<p>You use “Enqueue” methods to add work items to the list of things to do before the method should be considered a success. And the final thing you should do (in a successful test case) is call the TestComplete method on the base class. The EnqueueTestComplete can do this for you, if you like.</p>
<p>The work items built into the test framework are for calling some actions (EnqueueCallback), a conditional predicate enqueue (EnqueueConditional), and a dirty and evil-to-use EnqueueDelay method that will sleep a minimum amount of time before allowing other work items to run.</p>
<p>So, here’s a look at what happens when some regular tests run:</p>
<p><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="Simple set of test methods" border="0" alt="Simple set of test methods" src="http://media.jeff.wilcox.name/blog/view/WorkItemExample1.png" width="685" height="344" /> </p>
<p>And then a more complex run, with a test that includes some enqueued work that needs to execute – extending the test method to run beyond the lifetime of the actual initial test method that is executed:</p>
<p><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="Simple tests and a test with enqueued work items" border="0" alt="Simple tests and a test with enqueued work items" src="http://media.jeff.wilcox.name/blog/view/WorkItemExample2.png" width="685" height="506" /></p>
<h3>Using the enhanced test base classes</h3>
<p>All of the enqueue methods in the Silverlight unit test framework are <em>non-standard</em>, <em>unique</em>, and a little crazy. I say this because I don’t see Microsoft’s larger Visual Studio test team ever adopting this in a unit test framework – it is contrary to most execution principals for a test framework.</p>
<p>So if you use these enhanced base classes, you won’t necessarily be able to cross-compile them on the desktop unit test framework, and make use of them elsewhere. You’ve been warned!</p>
<p>A “work item” as the test framework uses them is a simple type (see reflector) that is evaluated for its completion state, and invoked. Once the work is complete, the work item will be removed from the test dispatcher, and execution will move on to the next work item in due time. A work item could be composite, in that its children are called and completed before the item itself reports a complete state.</p>
<p>If your test inherits from WorkItemTest (or PresentationTest, or SilverlightTest), you’ll be able to call from your tests:</p>
<h4>TestComplete()</h4>
<p>Instructs the framework that your test method is finished, and to move onto the next result. This can be added to event callbacks, delegates, etc. You should not do any more work or your test after calling this.</p>
<h4>EnqueueTestComplete</h4>
<p>Enqueues an action to call TestComplete. This is the most-used way of calling TestComplete when a set of work is done, and would typically be the last Enqueue* method call.</p>
<h4>EnqueueCallback</h4>
<p>Enqueues an Action (delegate, simple lambda, etc.). The work item effectively calls the Action, then moves on. Alternatively, this enqueue method also takes an array of Actions, allowing you to chain many Action calls together in order.</p>
<h4>EnqueueConditional</h4>
<p>Takes a Func&lt;bool&gt; conditional statement / predicate. Each time the work item is evaluated, the function is called. When it returns True, the work item is complete and execution will continue. After each invoke of the predicate, the test framework will unwind the stack, allowing other work to happen, before coming back to try the condition again.</p>
<h4>EnqueueDelay</h4>
<p>This method will enqueue a work item that takes either a TimeSpan object or an integer representing the number of milliseconds at minimum to delay before continuing. This is not an exact timer, but rather, a way to ensure that at least a minimum amount of time continues. It is more like a DoEvents call than it is like a Sleep call, since it will not block the UI thread.</p>
<p>We’re also looking to add support for the Timeout attribute in the future, so tests don’t run forever.</p>
<p>Of course, you can browse the complete source code to the test framework within the CodePlex source code for the <a href="http://www.codeplex.com/Silverlight/">Silverlight Toolkit</a>.</p>
<p>Typically, you’ll see a Silverlight test that prepares an object or control, adds it to the test surface, hooks up to the Loaded event for the control, then uses a set of enqueued conditionals and callbacks to validate a series of events or properties, finally calling TestComplete.</p>
<h3>Alternative Silverlight test frameworks</h3>
<p>Today are alternative frameworks available for those of you that would rather not test inside a browser. Many of us have already worked hard using this framework to test the platform itself, so the reward is that you can try something different in your test methods if you want to.</p>
<p>Some people on the web have made improvements or changes to the primary framework, others have come up with new and exciting takes on this all, including removing the runtime and Core CLR from the picture through extensive mocking:</p>
<ul>
<li><a href="http://blog.typemock.com/2009/02/silverunit-true-unit-testing-for.html">SilverUnit</a> is one such solution, and it’s written in VB.NET, too! Requires a TypeMock license.</li>
<li>Einar Ingebrigtsen’s <a href="http://www.ingebrigtsen.info/post/2009/01/12/Silverlight-Unit-Test-Runner-for-Resharper-January-2009-Update.aspx">Silverlight Unit Test Runner for Resharper</a></li>
<li><a href="http://code.google.com/p/silverlight-selenium/">Silverlight-Selenium</a> – adds support for Silverlight communication through the HTML interoperability feature of Silverlight 2</li>
<li>David Anson often runs his chart control tests on the desktop framework by using some clever mocking. I’ll ping him for details sometime.</li>
<li>I previously blogged how to use the same Silverlight unit test framework for running <a href="http://www.jeff.wilcox.name/2009/01/nunit-and-silverlight/">NUnit tests in the browser</a></li>
</ul>
<p>And, when it comes to mocking, there’s the SilverUnit listed above, plus:</p>
<ul>
<li><a href="http://ayende.com/projects/rhino-mocks/downloads.aspx">Rhino Mocks 3.5 for Silverlight</a></li>
<li><a href="http://code.google.com/p/moq/source/browse/#svn/build">Moq</a> – source available</li>
</ul>
<p>Let me know if I’ve left anything off the list, I’d like to link to other testing solutions as they come online. This is a space where I think the .NET community at large really is amazing.</p>
<p>Recently covering testing and Silverlight was <a href="http://timheuer.com/blog/archive/2009/02/26/silverlight-testing-frameworks.aspx">Tim Heuer</a>, and also <a href="http://silverlight.net/blogs/justinangel/archive/2009/02/25/silverlight-unit-testing-rhinomocks-unity-and-resharper.aspx">Justin Angel</a>. Check those posts out. </p>
<h3>History behind the thread decision</h3>
<p>When I started on this journey a few years ago, developing a robust, solid testing platform for Silverlight, the first internal release was actually using background threads &amp; even running in a separate host (not the browser). It was effectively a Core CLR testing platform that re-used the metadata from the Visual Studio unit test framework. Soon enough, it became clear that we needed to track down differences in the platform, beyond just letting our code run. There was a cause/effect to many operations, and we were primarily looking at control development and how to enable easy testing for both the development and the test teams in the company, when doing Silverlight work.</p>
<p>The VSTT metadata was still key, regardless of the execution environment, since so many people are familiar with it.</p>
<p>By redesigning the test product to instead be a Silverlight application itself, and run tests on the UI thread, we could improve the actual quality of our code by validating the platform along the way. We’re still finding positive side effects from this, and the only real cost has been the additional execution time compared to full CLR test solutions.</p>
<p>So, we settled on the UI thread for a majority of the testing. Yes, the exact opposite of what almost all other unit testing frameworks do. You would probably be really surprised to hear how many very interesting, and important, bugs we’ve found over the years of using this framework. Silverlight runtime changes, occasional regressions, parser issues, and a lot of key things that have actually improved the quality of Silverlight and the Silverlight control model in general.</p>
<p>Whether this exhaustive, in-the-browser execution may be good for your project may require some thought given your goals, since the tests are slower to run than alternatives. But if you’re doing anything wild (testing staged or live web services, wanting to test in all the browsers your customers use), etc., then you’ll find the Silverlight unit test framework to be real helpful. As a result, it also works on all those fun browsers that Silverlight works on – IE, Firefox, Firefox, and yeah, I even use it with Chrome. Works on Mac and PC, and I’m sure, someday soon, Moonlight.</p>
<p>What we have here is so much more than a “unit test framework,” and in my mind, this is actually a good base for some functional tests, plugging in additional reporting services, and much more involved that just running a few quick assertions on simple types behind the scenes. I know I’m ok with that, at least.</p>
<p>With the rich presentation platform’s emphasis on cross-platform, lightweight components, there’s a need to step away from a typical mocking solution. If you’ve ever wanted to perform verification of default templates, you probably understand the problem: the test needs a little time for the template to be applied after initialization, and you’ll be interested in how Silverlight actually processes that template.</p>
<p>In a nutshell, that’s where the [Asynchronous] attribute came from that the test execution logic handles to enable these test scenarios. Happy testing!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jeff.wilcox.name/2009/03/asynchronous-testing/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>NUnit &amp; the Silverlight unit test framework</title>
		<link>http://www.jeff.wilcox.name/2009/01/nunit-and-silverlight/</link>
		<comments>http://www.jeff.wilcox.name/2009/01/nunit-and-silverlight/#comments</comments>
		<pubDate>Wed, 07 Jan 2009 23:27:16 +0000</pubDate>
		<dc:creator>Jeff Wilcox</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Testing]]></category>

		<guid isPermaLink="false">http://www.jeff.wilcox.name/2009/01/nunit-and-silverlight/</guid>
		<description><![CDATA[Did you know that you can run NUnit tests with the Silverlight unit test framework? In this short guide, I talk about updating NUnit to build for Silverlight, wiring up test projects, and a download with everything you need to get started. This isn&#8217;t a &#34;metadata redirection&#34; trick &#8211; but the actual NUnit assertions and [...]]]></description>
			<content:encoded><![CDATA[<p>Did you know that you can run <a href="http://www.nunit.org/index.php">NUnit</a> tests with the Silverlight unit test framework? In this short guide, I talk about updating NUnit to build for Silverlight, wiring up test projects, and a download with everything you need to get started.</p>
<p>This isn&#8217;t a &quot;metadata redirection&quot; trick &#8211; but the actual NUnit assertions and metadata running inside the Silverlight unit test engine. This took about 15 minutes to implement from start to finish &#8211; shorter than the amount of time it&#8217;ll take me to publish this post.</p>
<p>Though NUnit is great for legacy components and tests, I strongly recommend using the <strong>built-in Visual Studio metadata</strong> for most projects. The metadata is used by enough folks throughout Microsoft and the industry to be well-supported, tested, familiar, and not require the custom unit test provider hookup in your test projects.</p>
<p>That said, I do hear about legacy business objects and NUnit tests that devs would like to be able to verify and run in the browser + Silverlight environment. </p>
<p>You can read about NUnit <a href="http://www.nunit.org/index.php?p=attributes&amp;r=2.4.8">attributes</a> and <a href="http://www.nunit.org/index.php?p=assertions&amp;r=2.4.8">assertions</a> in the official documentation. So, here goes&#8230;</p>
<h3>Running sample &amp; validation tests that ship with NUnit</h3>
<p>Inside the traditional <a href="http://www.nunit.org/index.php?p=download">NUnit source download</a>, there&#8217;s a sample called &quot;Money&quot; that tests a simple interface and types. Here&#8217;s that &quot;Money&quot; project running on <strong>OS X/Safari</strong>, via the Silverlight unit test framework and NUnit:</p>
<p><a href="http://media.jeff.wilcox.name/blog/ut/NUnitMoney/TestPage.html"><img src="http://media.jeff.wilcox.name/blog/ut/NUnitMoneyTest.png" /></a>&#160; <br /><em>&quot;Money&quot; sample test project: Click on the image or <a href="http://media.jeff.wilcox.name/blog/ut/NUnitMoney/TestPage.html">here to run</a> the Silverlight test application on your machine. Tests will start in ~5 seconds.</em></p>
<p>If you have a set of legacy business objects and associated NUnit tests, you&#8217;ll find it easy to run them within Silverlight now.</p>
<p>To further demonstrate the compatibility here, this is the &quot;NUnitTests&quot; test project that validates the core NUnit framework and its assertions, running inside Chrome:</p>
<p><a href="http://media.jeff.wilcox.name/blog/ut/NUnitTests/TestPage.html"><img src="http://media.jeff.wilcox.name/blog/ut/NUnitTests.png" /></a>     <br /><em>&quot;NUnitTests&quot; that validate the NUnit framework. Click on the image or <a href="http://media.jeff.wilcox.name/blog/ut/NUnitTests/TestPage.html">here to run</a> the tests.</em></p>
<h3>Silverlight unit test framework is easy to extend</h3>
<p>When designing the Silverlight unit test framework, it became clear that there were three or four distinct test engine components that could be combined into a single test system. Yet, they were distinct enough to allow alternative implementations and extensions to be built.</p>
<p><img src="http://media.jeff.wilcox.name/blog/ut/TestApplicationXap.png" /></p>
<p>The typical test application .XAP file ends up containing the general Silverlight unit testing engine (that performs test execution, and is very different from typical engines in that it runs on the UI thread and is synchronous), your actual tests marked with the appropriate metadata, and then the metadata and unit test assertions that you&#8217;re using.</p>
<p>Inside the unit test engine, there&#8217;s a base test harness class, and then the UnitTestHarness implementation that does most of the heavy lifting. A set of interfaces abstract out the reading and processing of unit test metadata. Interfaces aren&#8217;t always a great answer, but the value added in this case.</p>
<p>The metadata/assertion implementation that you use (NUnit or VSTT, for example) takes care of throwing exceptions when assertions fail, that the framework then processes in a generic way.</p>
<p>The Silverlight unit framework ships with the same metadata used in the Visual Studio team system&#8217;s unit test framework, making it easy to move between desktop and Silverlight application and test development. A &quot;VsttProvider&quot; sits between the Visual Studio metadata and the actual unit test engine, and ships in the Microsoft.Silverlight.Testing assembly.</p>
<p>OK. That&#8217;s a mouthful, but it means that you can implement your own metadata provider to support running other unit tests. Since NUnit and VSTT are so similar, this was easy &#8211; but more intricate frameworks might need to modify or extend the actual unit test system to provide the right experience.</p>
<h3>Getting NUnitFramework to build</h3>
<p>NUnit is relatively old; it is from a different era of .NET development. NUnit utilizes the old .NET Hashtable and ArrayList types.</p>
<p>Also, the .NET framework base class libaries included in Silverlight are a subset, rely more on .NET 3.5 features, and exclude some of the older types.</p>
<p>To easily support building NUnit with the Silverlight subset of the framework, here&#8217;s the list of changes I needed to make to the NUnitFramework project:</p>
<ul>
<li>Add simple implementations of Hashtable.cs and ArrayList.cs, utilizing modern generic collections under the hood </li>
<li>Inside ConstraintBuilder.cs, update the Stack type to be a generic Stack&lt;object&gt; </li>
<li>Added a shim/empty SerializableAttribute </li>
<li>Comment out constructors in IgnoreException.cs and AssertionException.cs that were designed for serialization (lines 33-35 and 35-37, respectively) </li>
<li><em>I removed the strong name assembly attributes from AssemblyInfo.cs, this isn&#8217;t actually required.</em> </li>
<li>On line 92 of CollectionConstaints.cs, changed the DictionaryEntry typed temporary variable to be of type &quot;var&quot; (since the Hashtable implementation is actually exposing a generic KeyValuePair now) </li>
</ul>
<p>So, I added a small &quot;CompatibilityShims&quot; Silverlight C# library project to the solution that included Hashtable, ArrayList, and SerializableAttribute.</p>
<h3>Wiring up test applications</h3>
<p>Unlike standard NUnit test projects, you will need to create an actual <strong>Silverlight application</strong> project for your tests. Once you create a new empty app, here&#8217;s what you should do:</p>
<ul>
<li>Remove the Page.xaml and Page.xaml.cs files</li>
<li>Add a reference to Microsoft.Silverlight.Testing.dll</li>
<li>Add a reference to the built NUnitFramework and NUnitSilverlight libraries and/or projects from this download</li>
<li>Inside App.xaml.cs, add using statements for the Microsoft.Silverlight.Testing and Microsoft.Silverlight.Testing.UnitTesting.Metadata.NUnit namespaces</li>
<li>Update Application_Startup per the instructions below</li>
<li>Add your tests and, if needed, a reference to your assembly/app under test</li>
</ul>
<p>Here&#8217;s what the startup code should look like for the test application:</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px" id="scid:887EC618-8FBE-49a5-A908-2339AF2EC720:52798c07-26cc-4e07-bf53-8874727ed8ec" class="wlWriterSmartContent">
<pre class="c-sharp" name="code">        private void Application_Startup(object sender, StartupEventArgs e)
        {
            UnitTestSystem.RegisterUnitTestProvider(new NUnitProvider());
            RootVisual = UnitTestSystem.CreateTestPage();
        }</pre>
</div>
<p>The code is similar to the regular Silverlight unit test startup code that you use for VSTT tests, except it first registers the NUnitProvider.</p>
<p>You can build and run the Silverlight application like any other: just press F5 and the tests will run!</p>
<h3>Using the Silverlight test framework&#8217;s asynchronous and Silverlight testing features</h3>
<p>Since the unit test engine is metadata-agnostic, it handles all the advanced asynchronous and Silverlight-specific test functions. Many of the core features specific to the Silverlight framework work with NUnit, therefore.</p>
<p>You&#8217;ll find that you can use:</p>
<ul>
<li>[Bug(...)] attributes</li>
<li>[Tag(...)] attributes. The Category NUnit attribute isn&#8217;t supported in this download, but you could easily modify the provider to expose Category data as Tags.</li>
<li>[Asynchronous], combined with deriving from SilverlightTest: support functional testing of user interface elements and controls.</li>
</ul>
<h3>Download the bits and samples</h3>
<p>I&#8217;m offering this as a proof-of-concept, unsupported download. Inside you&#8217;ll find everything that you need to explore the concept.</p>
<ul>
<li><a href="http://media.jeff.wilcox.name/blog/ut/NUnit.Silverlight.zip"><strong>NUnit.Silverlight.zip</strong></a> [266 KB], contains:</li>
</ul>
<ul>
<li>Unit test framework binaries</li>
<li>CompatibilityShims</li>
<li>NUnitFramework</li>
<li>&quot;NUnitSilverlight&quot; NUnit test provider for the Silverlight unit test framework</li>
<li>Sample test applications: &quot;Money&quot;, &quot;NUnitTests&quot;</li>
</ul>
<h3>Related resources</h3>
<ul>
<li><a href="http://www.jeff.wilcox.name/2008/08/utbasics/">Visual Studio unit testing intro</a> </li>
<li><a href="http://www.jeff.wilcox.name/2008/11/test-framework-source/">Silverlight unit test framework source released</a> </li>
<li><a href="http://www.jeff.wilcox.name/2008/10/ut-docs/">Reference documentation for the Silverlight unit test framework</a> </li>
<li><a href="http://www.jeff.wilcox.name/2008/09/rc0-new-test-features/">New test framework features for RC0/RTW</a> </li>
<li><a href="http://www.jeff.wilcox.name/2008/03/silverlight2-unit-testing/">Unit testing with Silverlight 2</a> </li>
</ul>
<p>Hope this helps!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jeff.wilcox.name/2009/01/nunit-and-silverlight/feed/</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
		<item>
		<title>R# integration for the Silverlight unit test framework</title>
		<link>http://www.jeff.wilcox.name/2008/12/r-integration-for-the-silverlight-unit-test-framework/</link>
		<comments>http://www.jeff.wilcox.name/2008/12/r-integration-for-the-silverlight-unit-test-framework/#comments</comments>
		<pubDate>Mon, 15 Dec 2008 03:29:33 +0000</pubDate>
		<dc:creator>Jeff Wilcox</dc:creator>
				<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Testing]]></category>
		<category><![CDATA[unit testing]]></category>

		<guid isPermaLink="false">http://www.jeff.wilcox.name/?p=192</guid>
		<description><![CDATA[If you&#8217;re a ReSharper user, check out Einar Ingebrigtsen&#8217;s blog, he&#8217;s updated his Silverlight unit test runner for R#. The original post about this technology is here.]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;re a <a href="http://www.jetbrains.com/resharper/">ReSharper</a> user, check out <a href="http://www.ingebrigtsen.info/default.aspx">Einar Ingebrigtsen&#8217;s blog</a>, he&#8217;s updated his <a href="http://www.ingebrigtsen.info/post/2008/12/11/Silverlight-Unit-Test-Runner-for-ReSharper-new-version.aspx">Silverlight unit test runner for R#</a>.</p>
<p>The original post about this technology is <a href="http://www.ingebrigtsen.info/post/2008/09/21/Silverlight-UnitTest-runner-for-Jetbrains-ReSharper.aspx">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jeff.wilcox.name/2008/12/r-integration-for-the-silverlight-unit-test-framework/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Silverlight unit test framework &#8211; updated source and binaries now available</title>
		<link>http://www.jeff.wilcox.name/2008/12/silverlight-unit-testing-december-2008/</link>
		<comments>http://www.jeff.wilcox.name/2008/12/silverlight-unit-testing-december-2008/#comments</comments>
		<pubDate>Tue, 09 Dec 2008 21:16:52 +0000</pubDate>
		<dc:creator>Jeff Wilcox</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Testing]]></category>

		<guid isPermaLink="false">http://www.jeff.wilcox.name/2008/12/09/silverlight-unit-testing-december-2008/</guid>
		<description><![CDATA[The latest release of the Silverlight Unit Test Framework is now available for download. This release contains a few simple bug fixes and was built with the RTM version of the Silverlight Tools. Download it today! Binaries and control sample tests, part of the Silverlight Toolkit download (you&#8217;ll find the bits in the .\Source\Binaries\ directory) [...]]]></description>
			<content:encoded><![CDATA[<p>The latest release of the Silverlight Unit Test Framework is now available for download. This release contains a few simple bug fixes and was built with the RTM version of the Silverlight Tools.</p>
<p>Download it today!</p>
<ul>
<li>Binaries and control sample tests, part of the <a href="http://www.codeplex.com/Silverlight/">Silverlight Toolkit download</a>      <br />(you&#8217;ll find the bits in the .\Source\Binaries\ directory)</li>
<li><a href="https://code.msdn.microsoft.com/Release/ProjectReleases.aspx?ProjectName=silverlightut&amp;ReleaseId=1913">Unit test framework binaries only</a></li>
<li><a href="http://www.codeplex.com/Silverlight/SourceControl/changeset/view/8631">Source code</a></li>
</ul>
<p>This interim release corrected a few simple issues that customers have reported, and is included along with the December 2008 release of the Silverlight Toolkit. Changes of note:</p>
<ul>
<li>Asynchronous exception handling fixes and improvements</li>
<li>[Priority(...)] attribute from VSTT is now supported. They receive implicit Tag values of PriorityN, where N is the integer priority.</li>
<li>WorkItemTest type: EnqueueDelay method added, has two method signatures that accept either the milliseconds to delay, or a TimeSpan object.</li>
<li>EnqueueCallback has a new overload that takes a number of Action parameters, for easy action chaining</li>
<li>Enqueue has been marked as obsolete: please use EnqueueCallback, for consistency</li>
<li>EnqueueSleep has been marked as obsolete: please use EnqueueDelay, which is a more clear name</li>
<li>Silverlight test service fixes, you can now run test applications from a web server in more scenarios</li>
<li>Silverlight test service can co-exist with other web servers and hosts</li>
</ul>
<p>Hope this helps.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jeff.wilcox.name/2008/12/silverlight-unit-testing-december-2008/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Creating a testable WebClient for Silverlight unit testing</title>
		<link>http://www.jeff.wilcox.name/2008/12/testable-webclient/</link>
		<comments>http://www.jeff.wilcox.name/2008/12/testable-webclient/#comments</comments>
		<pubDate>Sun, 07 Dec 2008 22:16:12 +0000</pubDate>
		<dc:creator>Jeff Wilcox</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Testing]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.jeff.wilcox.name/2008/12/07/testable-webclient/</guid>
		<description><![CDATA[Testability is important to today&#8217;s developers, and without a mocking framework available for Silverlight developers today, it is possible, albeit with a little extra work, to create testable components. Maurice de Beijer has blogged about his solution for creating a testable Flickr web service API. He&#8217;s created TestableWebClient and TestableOpenReadCompletedEventArgs types to assist with this, [...]]]></description>
			<content:encoded><![CDATA[<p>Testability is important to today&#8217;s developers, and without a mocking framework available for Silverlight developers today, it is possible, albeit with a little extra work, to create testable components.</p>
<p><a href="http://msmvps.com/blogs/theproblemsolver/">Maurice de Beijer</a> has blogged about his solution for <a href="http://msmvps.com/blogs/theproblemsolver/archive/2008/12/07/unit-testing-in-silverlight-part-2.aspx">creating a testable Flickr web service API</a>. He&#8217;s created TestableWebClient and TestableOpenReadCompletedEventArgs types to assist with this, and kept the abstraction simple and to-the-point.</p>
<p>I agree with Maurice&#8217;s comments: it isn&#8217;t perfect, it isn&#8217;t awful; it isn&#8217;t pretty; but hey, it does get the job done, and he&#8217;s found a good solution for this today.</p>
<p><a href="http://msmvps.com/blogs/theproblemsolver/archive/2008/12/07/unit-testing-in-silverlight-part-2.aspx"><img src="http://media.jeff.wilcox.name/blog/view/image_0C17D5DB.png" /></a> </p>
<p>Maurice also previously posted his own <a href="http://msmvps.com/blogs/theproblemsolver/archive/2008/12/02/unit-testing-in-silverlight-part-1.aspx">introduction guide to Silverlight unit testing</a>.</p>
<p>Just wanted to pass along, definitely check this out!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jeff.wilcox.name/2008/12/testable-webclient/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
