<?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>Nephandus &#187; Testing</title>
	<atom:link href="http://www.nephandus.com/tag/testing/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.nephandus.com</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Tue, 03 Jan 2012 16:33:48 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Unit Testing C# Webpages</title>
		<link>http://www.nephandus.com/2010/05/06/unit-testing-c-webpages/</link>
		<comments>http://www.nephandus.com/2010/05/06/unit-testing-c-webpages/#comments</comments>
		<pubDate>Thu, 06 May 2010 14:04:57 +0000</pubDate>
		<dc:creator>Chris</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Testing]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[software development]]></category>
		<category><![CDATA[tdd]]></category>
		<category><![CDATA[test driven development]]></category>
		<category><![CDATA[watir]]></category>
		<category><![CDATA[web development]]></category>

		<guid isPermaLink="false">http://www.nephandus.com/?p=21</guid>
		<description><![CDATA[Unit testing is good; test driven development is better.  As Knuth once famously quipped &#8220;Beware of the above code. I have only proven it correct, not tested it.&#8221; There really is no substitution for good, solid testing. Unfortunately, at least in C#, webpages don&#8217;t like to be unit tested.  I approach this post with an [...]]]></description>
			<content:encoded><![CDATA[<div id="attachment_22" class="wp-caption alignleft" style="width: 223px"><a href="http://www.flickr.com/photos/beatkueng/2680294816/"><img class="size-medium wp-image-22" title="2680294816_e710a43d3b" src="http://www.nephandus.com/wp-content/uploads/2010/05/2680294816_e710a43d3b-213x300.jpg" alt="" width="213" height="300" /></a><p class="wp-caption-text">Image Credit: PixelPlacebo via Flickr and Creative Commons</p></div>
<p>Unit testing is good; test driven development is better.  As Knuth once famously <a href="http://www-cs-faculty.stanford.edu/~knuth/faq">quipped</a> &#8220;<em>Beware of the above code. I have only proven it correct, not tested it.&#8221;</em> There really is no substitution for good, solid testing.</p>
<p>Unfortunately, at least in C#, webpages don&#8217;t like to be unit tested.  I approach this post with an uncomfortable realization that I am about to lay out the issues and problems I&#8217;ve had while the solution I am presently using is far from satisfactory.<span id="more-21"></span></p>
<p>There is a right way and a wrong way to undertake a lot of unit testing.  If you want to learn about that, I recommend <a href="http://www.ryanhagan.net/2009/10/test-driven-development/">this post by Ryan Hagan</a> as a great jumping off point.  My problem is not in writing good unit tests, however, so much as having a place to write them.</p>
<p>Axiomatic truth of Unit Testing: Your test code should exist in a different place than your production code.  This just makes good sense.  You don&#8217;t want to publish your tests every time you push code out the door and, since you want all of your published code to be tested you don&#8217;t want to have to write tests for your tests.  In C# the way one generally accomplishes this is the creation of a separate test project within the current solution.  That way the solution contains both your code and your tests.</p>
<p>Now generally, when you&#8217;re writing tests for C# this isn&#8217;t a big deal.  Since your project gets bundled up every time you build you can add a reference to the Test project that points at your main project; that way, the test harness knows what to make of all the custom types and whatnot that your various tests will have to evaluate.</p>
<p>This does not work for webpages.</p>
<p>When C# builds a webpage there&#8217;s no handy-dandy compiled thing at which to point your test code.  That means your test code has no idea what to make of any custom objects you&#8217;ve created and that makes any meaningful testing pretty much impossible.  Consider the following short example:</p>
<pre class="brush: csharp; title: ;">
public void CreateTest()
        {
            string WidgetName = string.Empty;
            Widget expected = null;
            Widget actual;
            actual = WidgetFactory_Accessor.Create(WidgetName);
            Assert.AreNotEqual(expected, actual);
       }
</pre>
<p>In this example, &#8220;Widget&#8221; and &#8220;WidgetFactory&#8221; are both custom types.  C# has conveniently generated an accessor for my Factory but it has no reference to my main project and thus doesn&#8217;t know what a Widget is.  Consequently, this test won&#8217;t compile and I can&#8217;t run it.</p>
<p>There is a work-around solution I&#8217;ve found wherein I publish the Main Project and then create a reference from the Test Project to the published AppCode.dll file.  This works but requires that I publish the DLL every time I wish to re-evaluate my source code which makes the entire testing process prohibitively time consuming.</p>
<p>My suspicion at this point is that what I am trying to do is in fact neither possible nor recommended and that unit testing of a C# webpage should be accomplished by creating a sharp distinction between the interface and presentation layers, testing the presentation layer traditionally and then using interface testing suites like <a href="http://watir.com/">Watir</a>.  This seems the sort of thing that should be verbosely stated somewhere if it is, indeed, the case.</p>
<h2>Update</h2>
<p>As per Ryan&#8217;s suggestion below and some other feedback I&#8217;ve gotten I am moving much of the logic code out of the project and creating a project-level distinction between the interface and the presentation layers of the application.  This should allow me to more sanely test the presentation layer and leverage Watin in to handle the interface testing.</p>
<p>It&#8217;s not the sort of separation recommended, but the architecture on this particular system is fairly dated and a full out re-factoring is out of the question (for now).</p>
<p>As it&#8217;s conspicuously missing from many other write-ups I&#8217;ve seen I&#8217;ll say it here.  You can not meaningfully test anything except the interface of a C# web project.  If you want to test your code, move it into a DLL project and allow your web project to call that DLL.  Ideally the Web project should be as thin as possible.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nephandus.com/2010/05/06/unit-testing-c-webpages/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Teaching An Old Dog New Tricks</title>
		<link>http://www.nephandus.com/2010/04/28/teaching-an-old-dog-new-tricks/</link>
		<comments>http://www.nephandus.com/2010/04/28/teaching-an-old-dog-new-tricks/#comments</comments>
		<pubDate>Wed, 28 Apr 2010 19:23:18 +0000</pubDate>
		<dc:creator>Chris</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Testing]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[ide]]></category>
		<category><![CDATA[interface]]></category>
		<category><![CDATA[software development]]></category>
		<category><![CDATA[syntax highlighter]]></category>
		<category><![CDATA[user testing]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.nephandus.com/?p=18</guid>
		<description><![CDATA[Most of the blogging I&#8217;ve done in the past has been political and thus I really haven&#8217;t had an opportunity to try to post much in the way of source code in a blog.  Once I got Nephandus up and running on WordPress, however, I thought I&#8217;d have a shot at it and thus posted [...]]]></description>
			<content:encoded><![CDATA[<div id="attachment_19" class="wp-caption alignleft" style="width: 206px"><a href="http://www.flickr.com/photos/dirkjankraan/4476149021/"><img class="size-medium wp-image-19" title="767 Cockpit" src="http://www.nephandus.com/wp-content/uploads/2010/04/4476149021_79176350b7-196x300.jpg" alt="" width="196" height="300" /></a><p class="wp-caption-text">How do you user test this?</p></div>
<p>Most of the blogging I&#8217;ve done in the past has been political and thus I really haven&#8217;t had an opportunity to try to post much in the way of source code in a blog.  Once I got Nephandus up and running on WordPress, however, I thought I&#8217;d have a shot at it and thus posted a short article on my experiences with C#&#8217;s serialization quirks.</p>
<p>To illustrate a specific point I included a brief snippet of C# code which WordPress promptly turned into an illegible mess.  The web is a notoriously difficult place to display source code and thus I set off in search of a WordPress plug-in that would allow me to do so without too much thought.  Several days, a dozen plug-ins, and a string of curse words that would make a sailor blush with shame, <a href="http://www.viper007bond.com/wordpress-plugins/syntaxhighlighter/">I have a solution</a>.</p>
<p>There is no shortage of syntax highlighting plug-ins available, but the support for their instantiation is practically non-existent.    Nephandus is running a number of plug-ins, none of which required much more than a few mouse-clicks to install and configure yet this particular task proved more difficult and involved than anything else I&#8217;ve done with WordPress.</p>
<p>The more I thought about this frustration the more I realized that this is an ongoing problem in the software development industry.<span id="more-18"></span></p>
<p>When developers buid a word processor or an email application they spend (or they should spend) a fair bit of time working out where users will intuitively look for certain basic functionality.  Tools, options, and commands should be where the user expects them to be; that saves time and cuts down on support costs.  We can test and evaluate that design by asking people who are totally unfamiliar with the product to find those sorts of functions and watching what they do.  It&#8217;s a system that works well because, familiar with the product or not, everyone has a basic grasp of certain tasks like writing or arithmetic.</p>
<p>But how do you do that kind of testing with an IDE?</p>
<p>The people who use IDEs are, pretty much by definition, super-users.  At the very least we can expect them to have a high level of familiarity, if not with the interface itself than with the thing the interface manipulates &#8211; code in a programming language they know.  These users have very specific ideas about where things ought to be which are based, not on intuition but where they were in some other IDE that they learned.  Because the population of knowledgeable coders is small and the number of IDEs they develop on is also small, it&#8217;s likely that they&#8217;ll bring some of their preconceived notions into user testing and that those notions will persist through the testing process.</p>
<p>Neophyte users aren&#8217;t terribly helpful because while they&#8217;re learning the interface they&#8217;re also learning the language and thus don&#8217;t know enough to evaluate the more powerful aspects of a product.</p>
<p>How then do you test the usability of a new interface when that interface&#8217;s intended users are a small, niche population often with preconceived, conflicting, and sometimes nearly religious notions of how the interface should look, feel, and act?</p>
<p>That isn&#8217;t a problem that WordPress plug-in authors really need to worry too much about &#8211; at least not if they&#8217;re giving their work away for free (beggars can&#8217;t be choosers) &#8211; but those of us who make specialty products for high-end niche professionals need to find a way to tackle the problem lest we find ourselves unable to change a 30 year old catastrophe of a design because it&#8217;s what everyone knows and expects.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nephandus.com/2010/04/28/teaching-an-old-dog-new-tricks/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

