<?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>distributedlife &#187; coding</title>
	<atom:link href="http://distributedlife.com/blog/category/coding/feed" rel="self" type="application/rss+xml" />
	<link>http://distributedlife.com/blog</link>
	<description>passionate about everything</description>
	<lastBuildDate>Sun, 31 Jul 2011 03:32:56 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Does Remote Directory Exist?</title>
		<link>http://distributedlife.com/blog/2009/10/does-remote-directory-exist.html</link>
		<comments>http://distributedlife.com/blog/2009/10/does-remote-directory-exist.html#comments</comments>
		<pubDate>Wed, 07 Oct 2009 13:55:28 +0000</pubDate>
		<dc:creator>Ryan Boucher</dc:creator>
				<category><![CDATA[coding]]></category>
		<category><![CDATA[automation]]></category>
		<category><![CDATA[c++]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[distributedlife]]></category>
		<category><![CDATA[hp]]></category>
		<category><![CDATA[ryan boucher]]></category>
		<category><![CDATA[rybo]]></category>
		<category><![CDATA[service test]]></category>
		<category><![CDATA[testing]]></category>
		<category><![CDATA[vanilla c]]></category>

		<guid isPermaLink="false">http://distributedlife.com/blog/?p=246</guid>
		<description><![CDATA[This code snippet is written in Vanilla C and HP Service Test C which adds a bunch of methods that make string manipulation and date type conversion just a little bit less painful. If any of you remember Vanilla C it was about as much fun as putting a pink sock in with the wedding [...]]]></description>
			<content:encoded><![CDATA[<p>This code snippet is written in Vanilla C and HP Service Test C which adds a bunch of methods that make string manipulation and date type conversion just a little bit less painful. If any of you remember Vanilla C it was about as much fun as putting a pink sock in with the wedding dress.</p>
<p>Chdir doesn&#8217;t work with UNC paths so we need another option. I already had the SysInternals tools installed so it made sense to use them.</p>
<p>If you want to know what is going on: lr_save_string takes a char* pointer and drops it into a HP Parameter and lr_eval_string returns a char* pointer evaluting items in brackets into their values. It&#8217;s much simpler than mucking about with sprintf.</p>
<pre><code class="cplusplus">
//Determine whether a remote directory exists
// - relies on psexec and xcopy and therefore Windows dependant
// - returns:
//      0 if path found
//      not zero if path is not found
int RemoteDirectoryExists (const char* server, const char* path)
{
    long FileHandle = 0 ;
    int Result = 1 ;

    lr_save_string (server, "__RemoteDirectoryExists_Server") ;

    //create batch file to be run on remote server that tries to chdir to the path
    FileHandle = fopen("dir.bat", "w") ;
    if (!FileHandle)
    {
        lr_error_message ("Unable to create the \"dir.bat\" file.") ;

        return Result ;
    }

    fprintf (FileHandle, "chdir %s", path) ;
    fclose (FileHandle) ;

    //xcopy batch file to remote server
    system (lr_eval_string ("xcopy /Y /Q \"dir.bat\" \\\\{__RemoteDirectoryExists_Server}\\c$\\temp\\*")) ;

    //psexec batch on remote
    Result = system (lr_eval_string ("psexec.exe \\\\{__RemoteDirectoryExists_Server} C:\\temp\\dir.bat")) ;

    return Result ;
}
</code></pre>
<p>Fairly simple really. It creates the batch file. Xcopies it to the remote server and then runs it locally via psexec. I use this in my automated deployment tests to check whether the install path has been removed after uninstall.</p>
]]></content:encoded>
			<wfw:commentRss>http://distributedlife.com/blog/2009/10/does-remote-directory-exist.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>It&#8217;s a long way to the cache&#8230;</title>
		<link>http://distributedlife.com/blog/2008/12/its-a-long-way-to-the-cache.html</link>
		<comments>http://distributedlife.com/blog/2008/12/its-a-long-way-to-the-cache.html#comments</comments>
		<pubDate>Mon, 15 Dec 2008 13:55:29 +0000</pubDate>
		<dc:creator>Ryan Boucher</dc:creator>
				<category><![CDATA[cakephp]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[cache]]></category>
		<category><![CDATA[database table not found]]></category>
		<category><![CDATA[performance]]></category>

		<guid isPermaLink="false">http://distributedlife.com/blog/?p=182</guid>
		<description><![CDATA[I had fun last night. I didn’t manage to waste too much time on this problem but I wasted more than none which is enough. CakePHP has a feature where it maintains a cached list of database tables it is aware of.
So I created a new table and the requisite model, controller, view files and [...]]]></description>
			<content:encoded><![CDATA[<p>I had fun last night. I didn’t manage to waste too much time on this problem but I wasted more than none which is enough. CakePHP has a <em>feature</em> where it maintains a cached list of database tables it is aware of.</p>
<p class="MsoNormal">So I created a new table and the requisite model, controller, view files and was ready to test it when CakePHP claimed my database table didn’t exist. It did and I spent plenty of time checking database connection strings and removing all but the simplest of code. I eventually found <a href="http://www.jroller.com/agileanswers/entry/missing_database_table_in_cake">this blog post by Eric Simmerman.</a></p>
<p class="MsoNormal">Delete the cache database table list and it all works fine. A simple fix and part of the reason for this post is to get Eric’s post closer to number one on a Google search. It wasn’t when I searched.</p>
<p class="MsoNormal">The answer I want to know is at what point did a cache become the final word? Caches are about performance enhancement and nothing else. You cache data so that you don’t have to go as far to get the answer. Distance is time is performance in computers. If you miss the cache then you go to your level two cache or you go to the persistent storage and get the data. The bottom line is that you keep going till you get an answer.</p>
<p class="MsoNormal">At no point in a cache do you ever say: “Well I don’t have it so you can bloody well sod off. No, I&#8217;m not going to ask around. I can’t see it, my eyes are closed and my fingers are in my ears. LA LA LA LA. ”</p>
<div style="border: 1pt solid windowtext; padding: 1pt 4pt; background: #e5b8b7 none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;">
<p class="MsoNormal" style="border: medium none; padding: 0cm; background: #e5b8b7 none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"><strong>Note:</strong> Don’t make me get my big red book of caching.</p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://distributedlife.com/blog/2008/12/its-a-long-way-to-the-cache.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Debugging Double Instances</title>
		<link>http://distributedlife.com/blog/2008/11/debugging-double-instances.html</link>
		<comments>http://distributedlife.com/blog/2008/11/debugging-double-instances.html#comments</comments>
		<pubDate>Wed, 19 Nov 2008 13:56:36 +0000</pubDate>
		<dc:creator>Ryan Boucher</dc:creator>
				<category><![CDATA[coding]]></category>
		<category><![CDATA[debugging]]></category>
		<category><![CDATA[class]]></category>
		<category><![CDATA[debug]]></category>
		<category><![CDATA[double]]></category>
		<category><![CDATA[duplicate]]></category>
		<category><![CDATA[instance]]></category>
		<category><![CDATA[object]]></category>

		<guid isPermaLink="false">http://distributedlife.com/blog/?p=176</guid>
		<description><![CDATA[I had a discussion with a friend at work today about the ways to identify a potential double instance of a class. Briefly, a double instance of a class, or any object, is when two objects are instantiated when only one should be and both are used at different times for the same purpose. This [...]]]></description>
			<content:encoded><![CDATA[<p class="MsoNormal" style="margin-bottom: 10pt;"><span style="font-family: ">I had a discussion with a friend at work today about the ways to identify a potential double instance of a class. Briefly, a double instance of a class, or any object, is when two objects are instantiated when only one should be and both are used at different times for the same purpose. This leaves you in a situation where you can see your data being set but when it comes to be used at a later point in time, possibly in a different part of the system, the data is no longer set.</span></p>
<p class="MsoNormal" style="margin-bottom: 10pt;"><span style="font-family: ">The easiest way to see if you have a double instance problem is to check the memory addresses at various stages of the program. If they differ and they shouldn’t then you have a problem. Finding the causes is a little bit harder.</span></p>
<p class="MsoNormal" style="margin-bottom: 10pt;"><span style="font-family: ">My first thought was to use a data breakpoint which is a handy little feature in some debuggers that throws a breakpoint when an address gets changed. Because these same debuggers always give the same memory addresses, assuming your application is deterministic, you will get notified when those address get written to.</span></p>
<p class="MsoNormal" style="margin-bottom: 10pt;"><span style="font-family: ">The simpler option is to place a breakpoint in the constructor and then check the call stack in each place your object is being instantiated. This works a treat but has a few caveats. Firstly you need to be working with classes, your class needs a constructor and it is easier to observe if you don’t have a plethora of objects being instantiated.</span></p>
<p class="MsoNormal" style="margin-bottom: 10pt;"><span style="font-family: ">The data breakpoint has the caveat that your debugger supports it and that it is enabled. For some reason in C# it wasn’t enabled.</span></p>
<p class="MsoNormal" style="margin-bottom: 10pt;">If you have any good ideas to add to the list, let me know.</p>
]]></content:encoded>
			<wfw:commentRss>http://distributedlife.com/blog/2008/11/debugging-double-instances.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>I have no idea</title>
		<link>http://distributedlife.com/blog/2008/11/i-have-no-idea.html</link>
		<comments>http://distributedlife.com/blog/2008/11/i-have-no-idea.html#comments</comments>
		<pubDate>Fri, 07 Nov 2008 15:51:20 +0000</pubDate>
		<dc:creator>Ryan Boucher</dc:creator>
				<category><![CDATA[coding]]></category>
		<category><![CDATA[life]]></category>
		<category><![CDATA[testing]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[internet explorer]]></category>
		<category><![CDATA[unit testing]]></category>

		<guid isPermaLink="false">http://distributedlife.com/blog/?p=169</guid>
		<description><![CDATA[ 
Have you ever been coding away, running tests, coding some more, running more tests and then having a large swathe of your tests fail. I did a few hours ago. I looked at it and thought to myself, nah, that can’t be right.
So I ran it again.
Many fails, not the same either. Most of [...]]]></description>
			<content:encoded><![CDATA[<p><!--[if gte mso 9]><xml> <w:WordDocument> <w:View>Normal</w:View> <w:Zoom>0</w:Zoom> <w:TrackMoves /> <w:TrackFormatting /> <w:PunctuationKerning /> <w:ValidateAgainstSchemas /> <w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid> <w:IgnoreMixedContent>false</w:IgnoreMixedContent> <w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText> <w:DoNotPromoteQF /> <w:LidThemeOther>EN-AU</w:LidThemeOther> <w:LidThemeAsian>X-NONE</w:LidThemeAsian> <w:LidThemeComplexScript>X-NONE</w:LidThemeComplexScript> <w:Compatibility> <w:BreakWrappedTables /> <w:SnapToGridInCell /> <w:WrapTextWithPunct /> <w:UseAsianBreakRules /> <w:DontGrowAutofit /> <w:SplitPgBreakAndParaMark /> <w:DontVertAlignCellWithSp /> <w:DontBreakConstrainedForcedTables /> <w:DontVertAlignInTxbx /> <w:Word11KerningPairs /> <w:CachedColBalance /> </w:Compatibility> <w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel> <m:mathPr> <m:mathFont m:val="Cambria Math" /> <m:brkBin m:val="before" /> <m:brkBinSub m:val="&#45;-" /> <m:smallFrac m:val="off" /> <m:dispDef /> <m:lMargin m:val="0" /> <m:rMargin m:val="0" /> <m:defJc m:val="centerGroup" /> <m:wrapIndent m:val="1440" /> <m:intLim m:val="subSup" /> <m:naryLim m:val="undOvr" /> </m:mathPr></w:WordDocument> </xml><![endif]--><!--[if gte mso 9]><xml> <w:LatentStyles DefLockedState="false" DefUnhideWhenUsed="true"   DefSemiHidden="true" DefQFormat="false" DefPriority="99"   LatentStyleCount="267"> <w:LsdException Locked="false" Priority="0" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="Normal" /> <w:LsdException Locked="false" Priority="9" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="heading 1" /> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 2" /> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 3" /> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 4" /> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 5" /> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 6" /> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 7" /> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 8" /> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 9" /> <w:LsdException Locked="false" Priority="39" Name="toc 1" /> <w:LsdException Locked="false" Priority="39" Name="toc 2" /> <w:LsdException Locked="false" Priority="39" Name="toc 3" /> <w:LsdException Locked="false" Priority="39" Name="toc 4" /> <w:LsdException Locked="false" Priority="39" Name="toc 5" /> <w:LsdException Locked="false" Priority="39" Name="toc 6" /> <w:LsdException Locked="false" Priority="39" Name="toc 7" /> <w:LsdException Locked="false" Priority="39" Name="toc 8" /> <w:LsdException Locked="false" Priority="39" Name="toc 9" /> <w:LsdException Locked="false" Priority="35" QFormat="true" Name="caption" /> <w:LsdException Locked="false" Priority="10" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="Title" /> <w:LsdException Locked="false" Priority="1" Name="Default Paragraph Font" /> <w:LsdException Locked="false" Priority="11" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="Subtitle" /> <w:LsdException Locked="false" Priority="22" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="Strong" /> <w:LsdException Locked="false" Priority="20" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="Emphasis" /> <w:LsdException Locked="false" Priority="59" SemiHidden="false"    UnhideWhenUsed="false" Name="Table Grid" /> <w:LsdException Locked="false" UnhideWhenUsed="false" Name="Placeholder Text" /> <w:LsdException Locked="false" Priority="1" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="No Spacing" /> <w:LsdException Locked="false" Priority="60" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Shading" /> <w:LsdException Locked="false" Priority="61" SemiHidden="false"    UnhideWhenUsed="false" Name="Light List" /> <w:LsdException Locked="false" Priority="62" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Grid" /> <w:LsdException Locked="false" Priority="63" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 1" /> <w:LsdException Locked="false" Priority="64" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 2" /> <w:LsdException Locked="false" Priority="65" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 1" /> <w:LsdException Locked="false" Priority="66" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 2" /> <w:LsdException Locked="false" Priority="67" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 1" /> <w:LsdException Locked="false" Priority="68" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 2" /> <w:LsdException Locked="false" Priority="69" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 3" /> <w:LsdException Locked="false" Priority="70" SemiHidden="false"    UnhideWhenUsed="false" Name="Dark List" /> <w:LsdException Locked="false" Priority="71" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Shading" /> <w:LsdException Locked="false" Priority="72" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful List" /> <w:LsdException Locked="false" Priority="73" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Grid" /> <w:LsdException Locked="false" Priority="60" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Shading Accent 1" /> <w:LsdException Locked="false" Priority="61" SemiHidden="false"    UnhideWhenUsed="false" Name="Light List Accent 1" /> <w:LsdException Locked="false" Priority="62" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Grid Accent 1" /> <w:LsdException Locked="false" Priority="63" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 1 Accent 1" /> <w:LsdException Locked="false" Priority="64" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 2 Accent 1" /> <w:LsdException Locked="false" Priority="65" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 1 Accent 1" /> <w:LsdException Locked="false" UnhideWhenUsed="false" Name="Revision" /> <w:LsdException Locked="false" Priority="34" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="List Paragraph" /> <w:LsdException Locked="false" Priority="29" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="Quote" /> <w:LsdException Locked="false" Priority="30" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="Intense Quote" /> <w:LsdException Locked="false" Priority="66" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 2 Accent 1" /> <w:LsdException Locked="false" Priority="67" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 1 Accent 1" /> <w:LsdException Locked="false" Priority="68" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 2 Accent 1" /> <w:LsdException Locked="false" Priority="69" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 3 Accent 1" /> <w:LsdException Locked="false" Priority="70" SemiHidden="false"    UnhideWhenUsed="false" Name="Dark List Accent 1" /> <w:LsdException Locked="false" Priority="71" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Shading Accent 1" /> <w:LsdException Locked="false" Priority="72" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful List Accent 1" /> <w:LsdException Locked="false" Priority="73" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Grid Accent 1" /> <w:LsdException Locked="false" Priority="60" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Shading Accent 2" /> <w:LsdException Locked="false" Priority="61" SemiHidden="false"    UnhideWhenUsed="false" Name="Light List Accent 2" /> <w:LsdException Locked="false" Priority="62" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Grid Accent 2" /> <w:LsdException Locked="false" Priority="63" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 1 Accent 2" /> <w:LsdException Locked="false" Priority="64" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 2 Accent 2" /> <w:LsdException Locked="false" Priority="65" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 1 Accent 2" /> <w:LsdException Locked="false" Priority="66" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 2 Accent 2" /> <w:LsdException Locked="false" Priority="67" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 1 Accent 2" /> <w:LsdException Locked="false" Priority="68" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 2 Accent 2" /> <w:LsdException Locked="false" Priority="69" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 3 Accent 2" /> <w:LsdException Locked="false" Priority="70" SemiHidden="false"    UnhideWhenUsed="false" Name="Dark List Accent 2" /> <w:LsdException Locked="false" Priority="71" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Shading Accent 2" /> <w:LsdException Locked="false" Priority="72" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful List Accent 2" /> <w:LsdException Locked="false" Priority="73" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Grid Accent 2" /> <w:LsdException Locked="false" Priority="60" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Shading Accent 3" /> <w:LsdException Locked="false" Priority="61" SemiHidden="false"    UnhideWhenUsed="false" Name="Light List Accent 3" /> <w:LsdException Locked="false" Priority="62" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Grid Accent 3" /> <w:LsdException Locked="false" Priority="63" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 1 Accent 3" /> <w:LsdException Locked="false" Priority="64" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 2 Accent 3" /> <w:LsdException Locked="false" Priority="65" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 1 Accent 3" /> <w:LsdException Locked="false" Priority="66" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 2 Accent 3" /> <w:LsdException Locked="false" Priority="67" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 1 Accent 3" /> <w:LsdException Locked="false" Priority="68" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 2 Accent 3" /> <w:LsdException Locked="false" Priority="69" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 3 Accent 3" /> <w:LsdException Locked="false" Priority="70" SemiHidden="false"    UnhideWhenUsed="false" Name="Dark List Accent 3" /> <w:LsdException Locked="false" Priority="71" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Shading Accent 3" /> <w:LsdException Locked="false" Priority="72" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful List Accent 3" /> <w:LsdException Locked="false" Priority="73" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Grid Accent 3" /> <w:LsdException Locked="false" Priority="60" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Shading Accent 4" /> <w:LsdException Locked="false" Priority="61" SemiHidden="false"    UnhideWhenUsed="false" Name="Light List Accent 4" /> <w:LsdException Locked="false" Priority="62" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Grid Accent 4" /> <w:LsdException Locked="false" Priority="63" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 1 Accent 4" /> <w:LsdException Locked="false" Priority="64" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 2 Accent 4" /> <w:LsdException Locked="false" Priority="65" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 1 Accent 4" /> <w:LsdException Locked="false" Priority="66" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 2 Accent 4" /> <w:LsdException Locked="false" Priority="67" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 1 Accent 4" /> <w:LsdException Locked="false" Priority="68" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 2 Accent 4" /> <w:LsdException Locked="false" Priority="69" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 3 Accent 4" /> <w:LsdException Locked="false" Priority="70" SemiHidden="false"    UnhideWhenUsed="false" Name="Dark List Accent 4" /> <w:LsdException Locked="false" Priority="71" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Shading Accent 4" /> <w:LsdException Locked="false" Priority="72" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful List Accent 4" /> <w:LsdException Locked="false" Priority="73" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Grid Accent 4" /> <w:LsdException Locked="false" Priority="60" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Shading Accent 5" /> <w:LsdException Locked="false" Priority="61" SemiHidden="false"    UnhideWhenUsed="false" Name="Light List Accent 5" /> <w:LsdException Locked="false" Priority="62" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Grid Accent 5" /> <w:LsdException Locked="false" Priority="63" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 1 Accent 5" /> <w:LsdException Locked="false" Priority="64" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 2 Accent 5" /> <w:LsdException Locked="false" Priority="65" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 1 Accent 5" /> <w:LsdException Locked="false" Priority="66" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 2 Accent 5" /> <w:LsdException Locked="false" Priority="67" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 1 Accent 5" /> <w:LsdException Locked="false" Priority="68" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 2 Accent 5" /> <w:LsdException Locked="false" Priority="69" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 3 Accent 5" /> <w:LsdException Locked="false" Priority="70" SemiHidden="false"    UnhideWhenUsed="false" Name="Dark List Accent 5" /> <w:LsdException Locked="false" Priority="71" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Shading Accent 5" /> <w:LsdException Locked="false" Priority="72" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful List Accent 5" /> <w:LsdException Locked="false" Priority="73" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Grid Accent 5" /> <w:LsdException Locked="false" Priority="60" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Shading Accent 6" /> <w:LsdException Locked="false" Priority="61" SemiHidden="false"    UnhideWhenUsed="false" Name="Light List Accent 6" /> <w:LsdException Locked="false" Priority="62" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Grid Accent 6" /> <w:LsdException Locked="false" Priority="63" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 1 Accent 6" /> <w:LsdException Locked="false" Priority="64" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 2 Accent 6" /> <w:LsdException Locked="false" Priority="65" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 1 Accent 6" /> <w:LsdException Locked="false" Priority="66" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 2 Accent 6" /> <w:LsdException Locked="false" Priority="67" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 1 Accent 6" /> <w:LsdException Locked="false" Priority="68" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 2 Accent 6" /> <w:LsdException Locked="false" Priority="69" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 3 Accent 6" /> <w:LsdException Locked="false" Priority="70" SemiHidden="false"    UnhideWhenUsed="false" Name="Dark List Accent 6" /> <w:LsdException Locked="false" Priority="71" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Shading Accent 6" /> <w:LsdException Locked="false" Priority="72" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful List Accent 6" /> <w:LsdException Locked="false" Priority="73" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Grid Accent 6" /> <w:LsdException Locked="false" Priority="19" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="Subtle Emphasis" /> <w:LsdException Locked="false" Priority="21" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="Intense Emphasis" /> <w:LsdException Locked="false" Priority="31" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="Subtle Reference" /> <w:LsdException Locked="false" Priority="32" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="Intense Reference" /> <w:LsdException Locked="false" Priority="33" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="Book Title" /> <w:LsdException Locked="false" Priority="37" Name="Bibliography" /> <w:LsdException Locked="false" Priority="39" QFormat="true" Name="TOC Heading" /> </w:LatentStyles> </xml><![endif]--> <!--[if gte mso 10]></p>
<style>
&nbsp;/* Style Definitions */
&nbsp;table.MsoNormalTable
&nbsp;{mso-style-name:"Table Normal";
&nbsp;mso-tstyle-rowband-size:0;
&nbsp;mso-tstyle-colband-size:0;
&nbsp;mso-style-noshow:yes;
&nbsp;mso-style-priority:99;
&nbsp;mso-style-qformat:yes;
&nbsp;mso-style-parent:"";
&nbsp;mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
&nbsp;mso-para-margin-top:0cm;
&nbsp;mso-para-margin-right:0cm;
&nbsp;mso-para-margin-bottom:10.0pt;
&nbsp;mso-para-margin-left:0cm;
&nbsp;line-height:115%;
&nbsp;mso-pagination:widow-orphan;
&nbsp;font-size:11.0pt;
&nbsp;font-family:"Calibri","sans-serif";
&nbsp;mso-ascii-font-family:Calibri;
&nbsp;mso-ascii-theme-font:minor-latin;
&nbsp;mso-hansi-font-family:Calibri;
&nbsp;mso-hansi-theme-font:minor-latin;
&nbsp;mso-fareast-language:EN-US;}
</style>
<p><![endif]--></p>
<p class="MsoNormal">Have you ever been coding away, running tests, coding some more, running more tests and then having a large swathe of your tests fail. I did a few hours ago. I looked at it and thought to myself, nah, that can’t be right.</p>
<p class="MsoNormal">So I ran it again.</p>
<p class="MsoNormal">Many fails, not the same either. Most of the problems seem to be establishing the system under test and that impacts the eventual results.</p>
<p class="MsoNormal">Rollback.</p>
<p class="MsoNormal">Fail.</p>
<p class="MsoNormal">What? These tests worked last night.</p>
<p class="MsoNormal">Run again.</p>
<p class="MsoNormal">Fail.</p>
<p class="MsoNormal">Fail.</p>
<p class="MsoNormal">Fail.</p>
<p class="MsoNormal">Ok, what is normally the cause of this? Caching! Let’s go and have a look at that. The caching code appears to be working as normal.</p>
<p class="MsoNormal">What if I comment out all of my tests except one?</p>
<p class="MsoNormal">That one fails 50% of the time. The same problem again. Failing when trying to establish the system under test. Look at the incredibly simple code and wonder how it could possible result in the scenario that being reported.</p>
<ol>
<li>I empty the database</li>
<li>I manually create two rows with two unique identifiers</li>
<li>I get an error saying that the database already has that row&#8230; ?</li>
</ol>
<p class="MsoNormal">Ok, halt execution after the first record creation. Everything is OK. Inputs for second row are correct. Still gets an error.</p>
<p class="MsoNormal">Hit refresh 50 times (these are web based tests here) in the dire hope I can exorcise the system.</p>
<p class="MsoNormal">Try it in Internet Explorer.</p>
<p class="MsoNormal">It works perfectly. No errors, no database issues, 100% passes as I have been getting for the past few weeks.</p>
<p class="MsoNormal">Go to a second machine and launch Firefox.</p>
<p class="MsoNormal">It works perfectly. No errors, no database issues, 100% passes as I have been getting for the past few weeks.</p>
<p class="MsoNormal">What is going on?</p>
<p class="MsoNormal">Back to dev box. Kill Firefox. Start again.</p>
<p class="MsoNormal">It works perfectly. No errors, no database issues, 100% passes as I have been getting for the past few weeks.</p>
<p class="MsoNormal">I hate computers.</p>
<p class="MsoNormal">What was the problem? I don’t know.</p>
<p class="MsoNormal">Will this affect the operation of my application in production? I don’t know.</p>
<p class="MsoNormal">Does this bother me? Yes.</p>
]]></content:encoded>
			<wfw:commentRss>http://distributedlife.com/blog/2008/11/i-have-no-idea.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Static Testing</title>
		<link>http://distributedlife.com/blog/2008/10/static-testing.html</link>
		<comments>http://distributedlife.com/blog/2008/10/static-testing.html#comments</comments>
		<pubDate>Tue, 21 Oct 2008 13:55:52 +0000</pubDate>
		<dc:creator>Ryan Boucher</dc:creator>
				<category><![CDATA[chuckles]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[compiler]]></category>
		<category><![CDATA[dynamic]]></category>
		<category><![CDATA[static]]></category>
		<category><![CDATA[unit testing]]></category>

		<guid isPermaLink="false">http://distributedlife.com/blog/?p=164</guid>
		<description><![CDATA[Now, I don’t subscribe to the philosophy of code your tests first, make them fail and then write your implementation. I prefer to write a method and then write the tests. It works better in my head. But just recently I’ve come across a pattern with my unit testing in dynamic languages where my unit [...]]]></description>
			<content:encoded><![CDATA[<p class="MsoNormal" style="text-align: justify;">Now, I don’t subscribe to the philosophy of code your tests first, make them fail and then write your implementation. I prefer to write a method and then write the tests. It works better in my head. But just recently I’ve come across a pattern with my unit testing in dynamic languages where my unit integration tests fail first time around and this is happening allot.</p>
<p class="MsoNormal" style="text-align: justify;">To make matters worse it is the same problem each time. The results come up, a bunch of assertion fails. After looking at the results and the test code for a few minutes I move over to the “integration” code to see what is wrong, all looks good. So I start checking the individual objects and their methods and the problem becomes obvious. I’ve not written the method, hell, I’ve not even written the class yet.</p>
<p class="MsoNormal" style="text-align: justify;">This is what I miss the most in dynamic languages. I’ve gotten use to employing static testing that tells me; you know what, before you run your tests, try finishing the freaking program.</p>
]]></content:encoded>
			<wfw:commentRss>http://distributedlife.com/blog/2008/10/static-testing.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CakePHP Unit Testing Gotchas</title>
		<link>http://distributedlife.com/blog/2008/10/cakephp-unit-testing-gotchas.html</link>
		<comments>http://distributedlife.com/blog/2008/10/cakephp-unit-testing-gotchas.html#comments</comments>
		<pubDate>Thu, 16 Oct 2008 13:55:41 +0000</pubDate>
		<dc:creator>Ryan Boucher</dc:creator>
				<category><![CDATA[cakephp]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[testing]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[unit testing]]></category>

		<guid isPermaLink="false">http://distributedlife.com/blog/?p=158</guid>
		<description><![CDATA[CakePHP has caused me some grief in the past week. Seemingly simple unit testing tasks were made much harder than they should have been. This post is for anyone else who encounters these problems.
The first relates to the testAction method used to test controllers. When putting a querystring in the url doesn&#8217;t cause it to [...]]]></description>
			<content:encoded><![CDATA[<p>CakePHP has caused me some grief in the past week. Seemingly simple unit testing tasks were made much harder than they should have been. This post is for anyone else who encounters these problems.<br />
The first relates to the testAction method used to test controllers. When putting a querystring in the url doesn&#8217;t cause it to be automatically parsed and split like it normally is when the controller is directly invoked.</p>
<p>For example:</p>
<pre class="chili"><code class="c++""""""""""""""">
$this-&gt;testAction(&#039;/testing/post?company=utCompany&#039;, array(&#039;return&#039; =&gt; &#039;vars&#039;)) ;
</code></pre>
<p>will result in:</p>
<pre class="chili"><code class="c++""""""""""""""">
[url] =&gt; /testing/post?company=utCompany
</code></pre>
<p>While invoking the url directly via the web browser results in:</p>
<pre class="chili"><code class="php""""""""""""""""""""">
[url] =&gt; Array
(
[url] =&gt; testing/post
[company] =&gt; utCompany
)
</code></pre>
<p>The solution I found is a bit of a hack. There is meant to be a fix in the pipeline but it’s not in my build and I am not ready to update to RC3 (and I’m not even sure if the fix is in RC3). Either way there is no guarantee this feature will work beyond RC2</p>
<p>If the second testAction parameter includes a named array called &#8216;url&#8217; then the values will be placed in the $this-&gt;params object in the controller. This gives us the same net result as when the controller is directly invoked. This is not documented in the CakePHP manual.</p>
<pre class="chili"><code class="php""""""""""""""""">
$data = array (&#039;company&#039; =&gt; &#039;utCompany&#039;) ;

$result = $this-&gt;testAction(&#039;/testing/post&#039;, array
(
&#039;return&#039; =&gt; &#039;vars&#039;,
&#039;method&#039; =&gt; &#039;get&#039;,
&#039;url&#039; =&gt; $data
)) ;
</code></pre>
<p>I originally asked this question on <a href="http://stackoverflow.com/questions/200925/how-to-pass-querystring-to-testaction-in-cakephp-12">StackOverflow</a> but had to answer it myself. Still I got four achievements out of that one question. Not a bad return on my investment.</p>
<p>The second problem relates to caching. It is summed up in this post by Wil Clouser called <a href="http://micropipes.com/blog/2008/01/07/cakephps-cache-that-wouldnt-quit/">The Cache that wouldn’t quit</a>. My problem was that I was taking a snapshot of my table before my query ran so I could validate the results. The query had only run just beforehand so CakePHP went to the cache and got my previously unchanged dataset. This one drove me spare. I always forget the cache when I test because my policy is that <strong>unless I am testing the cache, the cache is turned off.</strong></p>
<p>The solution is fairly simple. The query command (of which I use a lot rather than CakePHP’s “automagic”) accepts a second parameter called “false”. When supplied it turns caching off.</p>
<p>This still leaves you with a problem because you want to call methods in your model. Your model can’t default to no-cache otherwise your prod code wouldn’t have any caching. The easiest solution I came up with is the following.</p>
<p>All of your model code inherits from AppModel. Update AppModel with the following property.</p>
<pre class="chili"><code class="php""""""""""""""""">
class AppModel extends Model
{
var $useCache = &#039;true&#039; ;
}
</code></pre>
<p>Then in your test model override the attribute with a value of false.</p>
<pre class="chili"><code class="php""""""""""""""""">
class UserTest extends User
{
var $name = &#039;UserTest&#039;;
var $useTable = &#039;users&#039; ;
var $useDbConfig = &#039;test&#039;;
var $useCache = &#039;false&#039; ;
}
</code></pre>
<p>In between those two snippets is your User model. User inherits from AppModel but has no need to manage caching. When you write a method on your model you will need to add one more chunk of code.</p>
<pre class="chili"><code class="php""""""""""""""""">
$result = parent::query
(
&#039;SELECT
users.id
FROM
users
WHERE
users.name = \&#039;&#039; . $name . &#039;\&#039;
AND
users.suspended = 0&#039;,
$this-&gt;useCache
) ;
</code></pre>
<p>Note that $this-&gt;useCache is used as the second parameter. This then gives you the ability to ensure caching is turned off while your test your model.<br />
<!--[if gte mso 9]><xml> <w:WordDocument> <w:View>Normal</w:View> <w:Zoom>0</w:Zoom> <w:TrackMoves /> <w:TrackFormatting /> <w:PunctuationKerning /> <w:ValidateAgainstSchemas /> <w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid> <w:IgnoreMixedContent>false</w:IgnoreMixedContent> <w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText> <w:DoNotPromoteQF /> <w:LidThemeOther>EN-AU</w:LidThemeOther> <w:LidThemeAsian>X-NONE</w:LidThemeAsian> <w:LidThemeComplexScript>X-NONE</w:LidThemeComplexScript> <w:Compatibility> <w:BreakWrappedTables /> <w:SnapToGridInCell /> <w:WrapTextWithPunct /> <w:UseAsianBreakRules /> <w:DontGrowAutofit /> <w:SplitPgBreakAndParaMark /> <w:DontVertAlignCellWithSp /> <w:DontBreakConstrainedForcedTables /> <w:DontVertAlignInTxbx /> <w:Word11KerningPairs /> <w:CachedColBalance /> </w:Compatibility> <w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel> <m:mathPr> <m:mathFont m:val="Cambria Math" /> <m:brkBin m:val="before" /> <m:brkBinSub m:val="&#45;-" /> <m:smallFrac m:val="off" /> <m:dispDef /> <m:lMargin m:val="0" /> <m:rMargin m:val="0" /> <m:defJc m:val="centerGroup" /> <m:wrapIndent m:val="1440" /> <m:intLim m:val="subSup" /> <m:naryLim m:val="undOvr" /> </m:mathPr></w:WordDocument> </xml><![endif]--><!--[if gte mso 9]><xml> <w:LatentStyles DefLockedState="false" DefUnhideWhenUsed="true"   DefSemiHidden="true" DefQFormat="false" DefPriority="99"   LatentStyleCount="267"> <w:LsdException Locked="false" Priority="0" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="Normal" /> <w:LsdException Locked="false" Priority="9" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="heading 1" /> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 2" /> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 3" /> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 4" /> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 5" /> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 6" /> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 7" /> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 8" /> <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 9" /> <w:LsdException Locked="false" Priority="39" Name="toc 1" /> <w:LsdException Locked="false" Priority="39" Name="toc 2" /> <w:LsdException Locked="false" Priority="39" Name="toc 3" /> <w:LsdException Locked="false" Priority="39" Name="toc 4" /> <w:LsdException Locked="false" Priority="39" Name="toc 5" /> <w:LsdException Locked="false" Priority="39" Name="toc 6" /> <w:LsdException Locked="false" Priority="39" Name="toc 7" /> <w:LsdException Locked="false" Priority="39" Name="toc 8" /> <w:LsdException Locked="false" Priority="39" Name="toc 9" /> <w:LsdException Locked="false" Priority="35" QFormat="true" Name="caption" /> <w:LsdException Locked="false" Priority="10" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="Title" /> <w:LsdException Locked="false" Priority="1" Name="Default Paragraph Font" /> <w:LsdException Locked="false" Priority="11" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="Subtitle" /> <w:LsdException Locked="false" Priority="22" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="Strong" /> <w:LsdException Locked="false" Priority="20" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="Emphasis" /> <w:LsdException Locked="false" Priority="59" SemiHidden="false"    UnhideWhenUsed="false" Name="Table Grid" /> <w:LsdException Locked="false" UnhideWhenUsed="false" Name="Placeholder Text" /> <w:LsdException Locked="false" Priority="1" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="No Spacing" /> <w:LsdException Locked="false" Priority="60" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Shading" /> <w:LsdException Locked="false" Priority="61" SemiHidden="false"    UnhideWhenUsed="false" Name="Light List" /> <w:LsdException Locked="false" Priority="62" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Grid" /> <w:LsdException Locked="false" Priority="63" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 1" /> <w:LsdException Locked="false" Priority="64" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 2" /> <w:LsdException Locked="false" Priority="65" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 1" /> <w:LsdException Locked="false" Priority="66" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 2" /> <w:LsdException Locked="false" Priority="67" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 1" /> <w:LsdException Locked="false" Priority="68" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 2" /> <w:LsdException Locked="false" Priority="69" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 3" /> <w:LsdException Locked="false" Priority="70" SemiHidden="false"    UnhideWhenUsed="false" Name="Dark List" /> <w:LsdException Locked="false" Priority="71" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Shading" /> <w:LsdException Locked="false" Priority="72" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful List" /> <w:LsdException Locked="false" Priority="73" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Grid" /> <w:LsdException Locked="false" Priority="60" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Shading Accent 1" /> <w:LsdException Locked="false" Priority="61" SemiHidden="false"    UnhideWhenUsed="false" Name="Light List Accent 1" /> <w:LsdException Locked="false" Priority="62" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Grid Accent 1" /> <w:LsdException Locked="false" Priority="63" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 1 Accent 1" /> <w:LsdException Locked="false" Priority="64" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 2 Accent 1" /> <w:LsdException Locked="false" Priority="65" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 1 Accent 1" /> <w:LsdException Locked="false" UnhideWhenUsed="false" Name="Revision" /> <w:LsdException Locked="false" Priority="34" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="List Paragraph" /> <w:LsdException Locked="false" Priority="29" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="Quote" /> <w:LsdException Locked="false" Priority="30" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="Intense Quote" /> <w:LsdException Locked="false" Priority="66" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 2 Accent 1" /> <w:LsdException Locked="false" Priority="67" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 1 Accent 1" /> <w:LsdException Locked="false" Priority="68" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 2 Accent 1" /> <w:LsdException Locked="false" Priority="69" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 3 Accent 1" /> <w:LsdException Locked="false" Priority="70" SemiHidden="false"    UnhideWhenUsed="false" Name="Dark List Accent 1" /> <w:LsdException Locked="false" Priority="71" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Shading Accent 1" /> <w:LsdException Locked="false" Priority="72" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful List Accent 1" /> <w:LsdException Locked="false" Priority="73" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Grid Accent 1" /> <w:LsdException Locked="false" Priority="60" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Shading Accent 2" /> <w:LsdException Locked="false" Priority="61" SemiHidden="false"    UnhideWhenUsed="false" Name="Light List Accent 2" /> <w:LsdException Locked="false" Priority="62" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Grid Accent 2" /> <w:LsdException Locked="false" Priority="63" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 1 Accent 2" /> <w:LsdException Locked="false" Priority="64" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 2 Accent 2" /> <w:LsdException Locked="false" Priority="65" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 1 Accent 2" /> <w:LsdException Locked="false" Priority="66" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 2 Accent 2" /> <w:LsdException Locked="false" Priority="67" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 1 Accent 2" /> <w:LsdException Locked="false" Priority="68" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 2 Accent 2" /> <w:LsdException Locked="false" Priority="69" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 3 Accent 2" /> <w:LsdException Locked="false" Priority="70" SemiHidden="false"    UnhideWhenUsed="false" Name="Dark List Accent 2" /> <w:LsdException Locked="false" Priority="71" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Shading Accent 2" /> <w:LsdException Locked="false" Priority="72" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful List Accent 2" /> <w:LsdException Locked="false" Priority="73" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Grid Accent 2" /> <w:LsdException Locked="false" Priority="60" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Shading Accent 3" /> <w:LsdException Locked="false" Priority="61" SemiHidden="false"    UnhideWhenUsed="false" Name="Light List Accent 3" /> <w:LsdException Locked="false" Priority="62" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Grid Accent 3" /> <w:LsdException Locked="false" Priority="63" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 1 Accent 3" /> <w:LsdException Locked="false" Priority="64" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 2 Accent 3" /> <w:LsdException Locked="false" Priority="65" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 1 Accent 3" /> <w:LsdException Locked="false" Priority="66" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 2 Accent 3" /> <w:LsdException Locked="false" Priority="67" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 1 Accent 3" /> <w:LsdException Locked="false" Priority="68" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 2 Accent 3" /> <w:LsdException Locked="false" Priority="69" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 3 Accent 3" /> <w:LsdException Locked="false" Priority="70" SemiHidden="false"    UnhideWhenUsed="false" Name="Dark List Accent 3" /> <w:LsdException Locked="false" Priority="71" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Shading Accent 3" /> <w:LsdException Locked="false" Priority="72" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful List Accent 3" /> <w:LsdException Locked="false" Priority="73" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Grid Accent 3" /> <w:LsdException Locked="false" Priority="60" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Shading Accent 4" /> <w:LsdException Locked="false" Priority="61" SemiHidden="false"    UnhideWhenUsed="false" Name="Light List Accent 4" /> <w:LsdException Locked="false" Priority="62" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Grid Accent 4" /> <w:LsdException Locked="false" Priority="63" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 1 Accent 4" /> <w:LsdException Locked="false" Priority="64" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 2 Accent 4" /> <w:LsdException Locked="false" Priority="65" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 1 Accent 4" /> <w:LsdException Locked="false" Priority="66" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 2 Accent 4" /> <w:LsdException Locked="false" Priority="67" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 1 Accent 4" /> <w:LsdException Locked="false" Priority="68" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 2 Accent 4" /> <w:LsdException Locked="false" Priority="69" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 3 Accent 4" /> <w:LsdException Locked="false" Priority="70" SemiHidden="false"    UnhideWhenUsed="false" Name="Dark List Accent 4" /> <w:LsdException Locked="false" Priority="71" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Shading Accent 4" /> <w:LsdException Locked="false" Priority="72" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful List Accent 4" /> <w:LsdException Locked="false" Priority="73" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Grid Accent 4" /> <w:LsdException Locked="false" Priority="60" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Shading Accent 5" /> <w:LsdException Locked="false" Priority="61" SemiHidden="false"    UnhideWhenUsed="false" Name="Light List Accent 5" /> <w:LsdException Locked="false" Priority="62" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Grid Accent 5" /> <w:LsdException Locked="false" Priority="63" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 1 Accent 5" /> <w:LsdException Locked="false" Priority="64" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 2 Accent 5" /> <w:LsdException Locked="false" Priority="65" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 1 Accent 5" /> <w:LsdException Locked="false" Priority="66" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 2 Accent 5" /> <w:LsdException Locked="false" Priority="67" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 1 Accent 5" /> <w:LsdException Locked="false" Priority="68" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 2 Accent 5" /> <w:LsdException Locked="false" Priority="69" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 3 Accent 5" /> <w:LsdException Locked="false" Priority="70" SemiHidden="false"    UnhideWhenUsed="false" Name="Dark List Accent 5" /> <w:LsdException Locked="false" Priority="71" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Shading Accent 5" /> <w:LsdException Locked="false" Priority="72" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful List Accent 5" /> <w:LsdException Locked="false" Priority="73" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Grid Accent 5" /> <w:LsdException Locked="false" Priority="60" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Shading Accent 6" /> <w:LsdException Locked="false" Priority="61" SemiHidden="false"    UnhideWhenUsed="false" Name="Light List Accent 6" /> <w:LsdException Locked="false" Priority="62" SemiHidden="false"    UnhideWhenUsed="false" Name="Light Grid Accent 6" /> <w:LsdException Locked="false" Priority="63" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 1 Accent 6" /> <w:LsdException Locked="false" Priority="64" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Shading 2 Accent 6" /> <w:LsdException Locked="false" Priority="65" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 1 Accent 6" /> <w:LsdException Locked="false" Priority="66" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium List 2 Accent 6" /> <w:LsdException Locked="false" Priority="67" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 1 Accent 6" /> <w:LsdException Locked="false" Priority="68" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 2 Accent 6" /> <w:LsdException Locked="false" Priority="69" SemiHidden="false"    UnhideWhenUsed="false" Name="Medium Grid 3 Accent 6" /> <w:LsdException Locked="false" Priority="70" SemiHidden="false"    UnhideWhenUsed="false" Name="Dark List Accent 6" /> <w:LsdException Locked="false" Priority="71" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Shading Accent 6" /> <w:LsdException Locked="false" Priority="72" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful List Accent 6" /> <w:LsdException Locked="false" Priority="73" SemiHidden="false"    UnhideWhenUsed="false" Name="Colorful Grid Accent 6" /> <w:LsdException Locked="false" Priority="19" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="Subtle Emphasis" /> <w:LsdException Locked="false" Priority="21" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="Intense Emphasis" /> <w:LsdException Locked="false" Priority="31" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="Subtle Reference" /> <w:LsdException Locked="false" Priority="32" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="Intense Reference" /> <w:LsdException Locked="false" Priority="33" SemiHidden="false"    UnhideWhenUsed="false" QFormat="true" Name="Book Title" /> <w:LsdException Locked="false" Priority="37" Name="Bibliography" /> <w:LsdException Locked="false" Priority="39" QFormat="true" Name="TOC Heading" /> </w:LatentStyles> </xml><![endif]--> <!--[if gte mso 10]></p>
<style>
 /* Style Definitions */
 table.MsoNormalTable
	{mso-style-name:"Table Normal";
	mso-tstyle-rowband-size:0;
	mso-tstyle-colband-size:0;
	mso-style-noshow:yes;
	mso-style-priority:99;
	mso-style-qformat:yes;
	mso-style-parent:"";
	mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
	mso-para-margin-top:0cm;
	mso-para-margin-right:0cm;
	mso-para-margin-bottom:10.0pt;
	mso-para-margin-left:0cm;
	line-height:115%;
	mso-pagination:widow-orphan;
	font-size:11.0pt;
	font-family:"Calibri","sans-serif";
	mso-ascii-font-family:Calibri;
	mso-ascii-theme-font:minor-latin;
	mso-fareast-font-family:"Times New Roman";
	mso-fareast-theme-font:minor-fareast;
	mso-hansi-font-family:Calibri;
	mso-hansi-theme-font:minor-latin;}
</style>
<p><![endif]--></p>
<div style="border: 1pt solid windowtext; padding: 1pt 4pt; background: #e5b8b7 none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;">
<p class="MsoNormal" style="border: medium none; padding: 0cm; background: #e5b8b7 none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"><strong>Note:</strong> Apologies for the crap code highlighting. It isn’t working well. It is better than what it was before, which was self-hiding code&#8230;</p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://distributedlife.com/blog/2008/10/cakephp-unit-testing-gotchas.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Service Mockery and Automated Integration Testing</title>
		<link>http://distributedlife.com/blog/2008/10/service-mockery-and-automated-integration-testing.html</link>
		<comments>http://distributedlife.com/blog/2008/10/service-mockery-and-automated-integration-testing.html#comments</comments>
		<pubDate>Fri, 10 Oct 2008 13:55:52 +0000</pubDate>
		<dc:creator>Ryan Boucher</dc:creator>
				<category><![CDATA[coding]]></category>
		<category><![CDATA[mock]]></category>
		<category><![CDATA[service]]></category>
		<category><![CDATA[testing]]></category>
		<category><![CDATA[automated integration testing]]></category>
		<category><![CDATA[automation]]></category>
		<category><![CDATA[distributed services]]></category>
		<category><![CDATA[services]]></category>
		<category><![CDATA[soa]]></category>

		<guid isPermaLink="false">http://distributedlife.com/blog/?p=151</guid>
		<description><![CDATA[Service integration testing is an increasingly complicated task depending on how service interactions are defined. When you get to service orchestration and choreography then your integration testing is complex.
Ideally services, due to their nature, should have as much testing as possible automated. Automating all this is possible but like everything the cost to effort ratio [...]]]></description>
			<content:encoded><![CDATA[<p class="MsoNormal" style="text-align: justify;">Service integration testing is an increasingly complicated task depending on how service interactions are defined. When you get to service orchestration and choreography then your integration testing is complex.</p>
<p class="MsoNormal" style="text-align: justify;">Ideally services, due to their nature, should have as much testing as possible automated. Automating all this <strong>is possible</strong> but like everything the cost to effort ratio needs to be worked out. If the coders and testers work together then there is a solution to maximise the benefits from the effort.</p>
<p class="MsoNormal" style="text-align: justify;">When the coder is testing their service they will test the service internals (unit in isolation, unit integration testing) before moving to the service contract. If their service has dependencies on other services then they will probably mock out those services based on the service contract to effectively isolate the service and test it. With the clever use of mocks, the coder can establish a set of tests to perform some degree of non-functional testing (availability for example).</p>
<p class="MsoNormal" style="text-align: justify;">As they are by themselves these mocks are not being reused by other consumers of the mocked service, this means that each coder will need to mock the service for its own uses. This is fairly common; with some of the cool mocking frameworks out there it is easy to quickly mock out your dependencies.</p>
<p class="MsoNormal" style="text-align: justify;">I propose that the coders build up a shared mock library for use in service testing. Like coffee it has its disadvantages but its advantages extend into the realm of the tester as well.</p>
<h3>Mock libraries</h3>
<p class="MsoNormal" style="text-align: justify;">One of the biggest problems with a mock library is the need to maintain mocks over the course of development. Not only do unit tests need to be maintained, but mocks as well. The second is the need to manage the versioning of mock services with their versioned service counterparts. Without these two things then the mock library will get out of date and fall into disuse.</p>
<p class="MsoNormal" style="text-align: justify;">On top of this in a large development shop you have the problem of mock discovery, where it is stored in version control, mock ownership. I could wrap it all in the grandiose term Mock Governance but in reality it isn’t that complicated and doesn’t need that much management. It just needs to be thought about before you start.</p>
<p class="MsoNormal" style="text-align: justify;">The benefits of a mock library are such that each service has this framework of code around it to ensure that it works correctly. As you build the service, unit tests are written to make sure the internals work correctly. As its consumers are being built, mocks are being written to ensure that they handle the services behaviour correctly.</p>
<p class="MsoNormal" style="text-align: justify;">A bigger benefit is seen when we move into the<strong> established integration testing environments</strong>. When the testers get their hand on the service code they are going to try and do two things. Test the service interfaces to see if they work and secondly; test the service integration to make sure that they services work together.</p>
<p class="MsoNormal" style="text-align: justify;">The service integration as mentioned before is the hard part. With many possible combinations of services and a variety of behaviours coming out of each service the permutations can escalate out of control. Naturally not everything can be tested and what can be tested can be made easier.</p>
<h3>Automated Integration Testing</h3>
<p class="MsoNormal" style="text-align: justify;">If you take a tool like <a href="http://www.capify.org/">Capistrano</a> and use it to build a suite of deployment scripts. These scripts deploy combinations of real services and mock services automatically. These scripts become your automated integration tests. You can setup your integration environment to simulate the deployment of one service and five mock services to see how it handles the unavailability of its dependencies. You could deploy the real version of all the services to your performance testing environment. Add a mock consumer to simulate the UI layer and you can generate some load on your services to see how it handles.</p>
<p class="MsoNormal" style="text-align: justify;">If you have a virtualisation server sitting idle you can spin up multiple instances of your service integration at the same time. This can reduce the time to test. When testing integration you don’t always need the entire environment replicated for your test, just the nodes that are within the scope of your test.</p>
<h3>Why not service testing tools?</h3>
<p class="MsoNormal" style="text-align: justify;">Service testing tools basically provide a wrapper UI for a service. This allows the tester to generate test scripts for validating the interface. The coders however, tested that when they tested the service in isolation. The tester should verify the results, but there is no need to duplicate the effort.</p>
<p class="MsoNormal" style="text-align: justify;">The next problem is that if the service has dependencies and they don’t exist, how is a UI wrapper to the service going to help? You are going to find out how well the service handles not having any of its dependencies but you won’t be able to handle any other integration scenarios.</p>
<p class="MsoNormal" style="text-align: justify;">If you ever get to a situation where at least one service in development is lagging behind your integration testing has to wait. Why wait when you can mock and prove that the service behaves under specific scenarios. When you finally get your complete set of services, you can perform full end to end tests using live versions.</p>
<p class="MsoNormal" style="text-align: justify;">It’s not all sour for service testing tools, some tools do handle aspects of load generation and service result verification, but the way I see <strong>it’s a lot of money spent and you are not even getting the benefit of automated service integration testing</strong>. The complexity of service integration is what makes testing services hard. In comparison service interface testing is trivial.</p>
<h3>Why don’t the coders write the Integration tests?</h3>
<p class="MsoNormal" style="text-align: justify;">I said that the testers would be writing these inherently code-like scripts. The coders can if they want, there is no reason that they can’t but there are couple of considerations to be kept in mind before making the decision.</p>
<p class="MsoNormal" style="text-align: justify;">The first the skilling issue and whether or not your developers have the necessary skill set and mindset to adequately create the right scripts to provide good test coverage. The second is a resourcing issue. You have N number of developers. Do they have time to write integration tests as well as their unit and service in isolation testing? If they do, good, I’m sure they will get a kick out of writing scripts to spin up virtual machines establish the system under test, let it loose and bring it all down again. It is pretty cool.</p>
<h3>A Final Sell</h3>
<p class="MsoNormal" style="text-align: justify;">There are other benefits to come all of this. Deployment testing is given a solid workout with each integration test potentially establishing the system under test each time it is run. The automated integration testing scripts can be reused for future work and can be included in a continuous integration server that exercises each new build. It would be nice to know that when I make a code change I can still see whether my service is still integrating with it consumers and dependencies.</p>
<p class="MsoNormal" style="text-align: justify;">The scripts can be used to develop scoped performance, load and stress tests. By creating mocks that enact scenarios of high load (high latency or low throughput) you more easily determine if your load balancer will scale up or out correctly.<span> </span></p>
<p class="MsoNormal" style="text-align: justify;">
<div style="border: 1pt solid windowtext; padding: 1pt 4pt; background: #e5b8b7 none repeat scroll 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;">
<p class="MsoNormal" style="border: medium none; padding: 0cm; background: #e5b8b7 none repeat scroll 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"><strong>Note: </strong>This<strong> </strong>doesn’t just apply to services, any integration heavy architectural solution can benefit from a good Mock Library and automated integrated testing.</p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://distributedlife.com/blog/2008/10/service-mockery-and-automated-integration-testing.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Code Coverage</title>
		<link>http://distributedlife.com/blog/2008/09/code-coverage.html</link>
		<comments>http://distributedlife.com/blog/2008/09/code-coverage.html#comments</comments>
		<pubDate>Sun, 14 Sep 2008 13:55:03 +0000</pubDate>
		<dc:creator>Ryan Boucher</dc:creator>
				<category><![CDATA[coding]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://distributedlife.com/blog/?p=132</guid>
		<description><![CDATA[A word of warning for people using code coverage, there is a difference between code coverage and testing coverage. I know that this shouldn’t be news to some people, but it keeps cropping up again and again. Currently the Wikipedia article on Code Coverage claims that it is with this gooey nugget of falsehood.

Code coverage [...]]]></description>
			<content:encoded><![CDATA[<p class="MsoNormal" style="text-align: justify;"><span>A word of warning for people using code coverage, there is a difference between code coverage and testing coverage. I know that this shouldn’t be news to some people, but it keeps cropping up again and again. Currently the Wikipedia article on Code Coverage claims that it is with this gooey nugget of falsehood.</span></p>
<div style="border: 1pt solid windowtext; padding: 1pt 4pt; background: #c4bc96 none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; margin-left: 36pt; margin-right: 36pt;">
<p class="MsoNormal" style="border: medium none; padding: 0cm; background: #c4bc96 none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"><strong>Code coverage</strong> is a measure used in software testing. It describes the degree to which the source code of a program has been tested. It is a form of testing that inspects the code directly and is therefore a form of white box testing.</p>
</div>
<p class="MsoNormal" style="text-align: justify;">
<p class="MsoNormal" style="text-align: justify;">In Wikipedia’s defence it does say that the article does not cite any references or sources. This is good a thing because nobody would want to be associated with that statement.</p>
<p class="MsoNormal" style="text-align: justify;">Now I like code coverage. I like statistics, so why wouldn’t I like code coverage. It’s a cool statistic that lets you know some information about the code you are writing and the unit tests that accompany your code. Code coverage can hint to you where additional unit tests should be written. This would be where one type of code coverage is low or even zero.</p>
<p class="MsoNormal" style="text-align: justify;">Code coverage can also give you a false sense of security. This is what worries me. I see people thinking that code coverage is test coverage. Test coverage is the percentage of tests that cover requirements. When you get into permutations and combinations test coverage itself can be a very unrealistic measure of how tested a system truly is.</p>
<p class="MsoNormal" style="text-align: justify;">This is where experienced testers come in to determine what percentage of test cases are on the critical path and what percentage are not. The same applies for unit tests and code coverage. By itself code coverage is a statistic that can easily be misread or abused, with an experienced developer the relevancy of the statistic is brought out and useful unit tests are written.</p>
<p class="MsoNormal" style="text-align: justify;">I will provide an example of where code coverage reports that the world is rosy, but in reality this code wouldn’t pass test. My example is obviously contrived to illustrate my point. In real life a moderately skilled developer would have built a unit test to sufficiently test this code.</p>
<p class="MsoNormal"><strong><span class="MsoBookTitle">Our Code (C++)</span></strong></p>
<div style="border: 1pt solid windowtext; padding: 1pt 4pt; background: #d6e3bc none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; margin-left: 36pt; margin-right: 36pt;">
<p class="MsoNoSpacing" style="border: medium none; padding: 0cm; background: #d6e3bc none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"><span style="font-size: 10pt; font-family: "> </span></p>
<p class="MsoNoSpacing" style="border: medium none; padding: 0cm; background: #d6e3bc none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"><span style="font-size: 10pt; font-family: ">float reciprocal (const float ex)</span></p>
<p class="MsoNoSpacing" style="border: medium none; padding: 0cm; background: #d6e3bc none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"><span style="font-size: 10pt; font-family: ">{</span></p>
<p class="MsoNoSpacing" style="border: medium none; padding: 0cm; background: #d6e3bc none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"><span style="font-size: 10pt; font-family: "><span> </span>return (1.0f / ex) ;</span></p>
<p class="MsoNoSpacing" style="border: medium none; padding: 0cm; background: #d6e3bc none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"><span style="font-size: 10pt; font-family: ">}</span></p>
<p class="MsoNoSpacing" style="border: medium none; padding: 0cm; background: #d6e3bc none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"><span style="font-size: 10pt; font-family: "> </span></p>
</div>
<p class="MsoNormal"><strong><br />
</strong></p>
<p class="MsoNormal"><strong><span class="MsoBookTitle">Our Unit Test</span></strong></p>
<div style="border: 1pt solid windowtext; padding: 1pt 4pt; background: #d6e3bc none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; margin-left: 36pt; margin-right: 36pt;">
<p class="MsoNoSpacing" style="border: medium none; padding: 0cm; background: #d6e3bc none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"><span style="font-size: 10pt; font-family: "> </span></p>
<p class="MsoNoSpacing" style="border: medium none; padding: 0cm; background: #d6e3bc none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"><span style="font-size: 10pt; font-family: ">Assert.AreEqual (1.0f, reciprocal (1.0f)) ;</span></p>
<p class="MsoNoSpacing" style="border: medium none; padding: 0cm; background: #d6e3bc none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"><span style="font-size: 10pt; font-family: "> </span></p>
</div>
<p class="MsoNormal"><span class="MsoBookTitle"> </span></p>
<p class="MsoNormal">
<p class="MsoNormal"><strong><span class="MsoBookTitle">Our Code Coverage</span></strong></p>
<ul>
<li>Statement Coverage = 100%</li>
<li>Branch Coverage = 100%</li>
</ul>
<p class="MsoNormal">
<p class="MsoNormal" style="text-align: justify;">Taking the statistics at face value it would be time to stop working on this code because it cannot be more perfect than this. For those that don’t know, and non-coders may be reading this, there needs to be at least one more unit test where the value of X (ex) is zero. This will cause a divide by zero exception. For completeness one would add the following tests for X (0.0, 1.0, -1.0, a positive and negative value that is less than +/-1.0f and a positive and negative value that is greater than +/-1.0f).</p>
<p class="MsoNormal" style="text-align: justify;">The important thing to take home from all of this is that code coverage, like many other tools, figures, statistics and adages, are designed to impart information. Making an educated decision based upon such information is where you come in.</p>
<div style="border: 1pt solid windowtext; padding: 1pt 4pt; background: #e5b8b7 none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;">
<p class="MsoNormal" style="border: medium none; padding: 0cm; background: #e5b8b7 none repeat scroll 0% 0%; text-align: justify; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"><strong>Note:</strong> I have put a comment on the Wikipedia article stating that I suggesting changing the article to something like: <em>Code Coverage reports on the percentage of lines of source code that are executed by one or more test cases.</em> Ideally I would like them to cover the misuses of the statistic a little more, we shall see what happens.</p>
<p class="MsoNormal" style="border: medium none; padding: 0cm; background: #e5b8b7 none repeat scroll 0% 0%; text-align: justify; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"><strong>2nd Note: </strong>This is a post about code coverage, not the standard of Wikipedia.</p>
</div>
<p class="MsoNormal" style="text-align: justify;">
]]></content:encoded>
			<wfw:commentRss>http://distributedlife.com/blog/2008/09/code-coverage.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Psychics</title>
		<link>http://distributedlife.com/blog/2008/08/psychics.html</link>
		<comments>http://distributedlife.com/blog/2008/08/psychics.html#comments</comments>
		<pubDate>Fri, 22 Aug 2008 16:58:06 +0000</pubDate>
		<dc:creator>Ryan Boucher</dc:creator>
				<category><![CDATA[coding]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://distributedlife.com/blog/?p=123</guid>
		<description><![CDATA[Psychics are a special property that can exist on any object in any programming language. To mark an object as psychic, simply include a relationship to another object within your framework, API or system. The compiler/interpreter will ensure that any documentation that is generated from the source code or is written by hand, if you [...]]]></description>
			<content:encoded><![CDATA[<p>Psychics are a special property that can exist on any object in any programming language. To mark an object as psychic, simply include a relationship to another object within your framework, API or system. The compiler/interpreter will ensure that any documentation that is generated from the source code or is written by hand, if you ever wrote documentation, is removed. This is to ensure that anyone attempting to use your code won&#8217;t be able to work why your framework doesn&#8217;t work in certain scenarios.</p>
<p>A free tip to anyone writing source code anywhere for any reason. If you make a dependency on another object and then silently fallback to reduced functionality when that object is not supplied, write it down. Don&#8217;t stop there, formally document in comic sans so that everyone notices the glaring type and takes note. If you really feel like helping people who licence your codebase, document the dependency in the dependant object. The following text is often sufficient:</p>
<blockquote><p><em>Feature X on this object is not available unless Object Y exists and is correctly configured.</em></p></blockquote>
<p><strong>Note: </strong>For all those that ask, this is how I like to spend my Friday nights.</p>
]]></content:encoded>
			<wfw:commentRss>http://distributedlife.com/blog/2008/08/psychics.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>No that hasn&#8217;t changed</title>
		<link>http://distributedlife.com/blog/2008/06/no-that-hasnt-changed.html</link>
		<comments>http://distributedlife.com/blog/2008/06/no-that-hasnt-changed.html#comments</comments>
		<pubDate>Sat, 14 Jun 2008 13:55:00 +0000</pubDate>
		<dc:creator>Ryan Boucher</dc:creator>
				<category><![CDATA[coding]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://distributedlife.com/blog/?p=43</guid>
		<description><![CDATA[If you ever find yourself in a situation where existing functionality has stopped working due to development of new functionality. Rather than saying that you haven&#8217;t changed the old code. Do a diff on the previous check-in and move on.
]]></description>
			<content:encoded><![CDATA[<p>If you ever find yourself in a situation where existing functionality has stopped working due to development of new functionality. Rather than saying that you haven&#8217;t changed the old code. Do a diff on the previous check-in and move on.</p>
]]></content:encoded>
			<wfw:commentRss>http://distributedlife.com/blog/2008/06/no-that-hasnt-changed.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

