<?xml version="1.0" encoding="utf-8"?>
			
			<rss version="2.0">
			<channel>
			<title>Bob&apos;s Blog - ColdFusion Tidbits - TDD</title>
			<link>http://www.silverwareconsulting.com/index.cfm</link>
			<description>Some stuff about ColdFusion and Transfer</description>
			<language>en-us</language>
			<pubDate>Thu, 09 Sep 2010 05:22:00 -0400</pubDate>
			<lastBuildDate>Thu, 17 Jun 2010 10:49:00 -0400</lastBuildDate>
			<generator>BlogCFC</generator>
			<docs>http://blogs.law.harvard.edu/tech/rss</docs>
			<managingEditor>bob.silverberg@gmail.com</managingEditor>
			<webMaster>bob.silverberg@gmail.com</webMaster>
			
			<item>
				<title>My Interview on WebDevRadio</title>
				<link>http://www.silverwareconsulting.com/index.cfm/2010/6/17/My-Interview-on-WebDevRadio</link>
				<description>
				
				I had the honour and pleasure of being interviewed by &lt;a href=&quot;http://michaelkimsal.com/blog/&quot; target=&quot;_blank&quot;&gt;Michael Kimsal&lt;/a&gt; for his 
&lt;a href=&quot;http://webdevradio.com/&quot; target=&quot;_blank&quot;&gt;WebDevRadio podcast&lt;/a&gt; a few weeks ago. 
The episode was published last week and is now available for listening and/or downloading from 
the &lt;a href=&quot;http://webdevradio.com/index.php?id=103&quot; target=&quot;_blank&quot;&gt;podcast website&lt;/a&gt;, as well as 
via &lt;a href=&quot;http://itunes.apple.com/podcast/webdevradio-com-web-development/id74402299&quot; target=&quot;_blank&quot;&gt;iTunes&lt;/a&gt;.&lt;/p&gt; 
&lt;p&gt;For those of you that don&apos;t know Michael, you&apos;re missing out. I met him at &lt;a href=&quot;http://ncdevcon.com&quot; target=&quot;_blank&quot;&gt;NCDevCon&lt;/a&gt; and found him to be an extremely pleasant, funny and smart individual.
I enjoyed my chats with him at the conference, and really enjoyed discussing all sorts of topics with him for the podcast, including, 
but not limited to, how I came to develop using ColdFusion, contributing to open source projects, test-driven development and unit testing in general, and
object-relational mapping (ORM) in ColdFusion. I also really appreciated the opportunity to have my voice heard outside of the ColdFusion community.&lt;/p&gt; 
				</description>
				
				<category>TDD</category>				
				
				<category>ColdFusion</category>				
				
				<category>Podcasts</category>				
				
				<pubDate>Thu, 17 Jun 2010 10:49:00 -0400</pubDate>
				<guid>http://www.silverwareconsulting.com/index.cfm/2010/6/17/My-Interview-on-WebDevRadio</guid>
				
			</item>
			
			<item>
				<title>Checking for JavaScript Errors with Selenium</title>
				<link>http://www.silverwareconsulting.com/index.cfm/2010/6/7/Checking-for-JavaScript-Errors-with-Selenium</link>
				<description>
				
				I&apos;ve recently been writing some end-to-end tests for &lt;a href=&quot;http://www.validatethis.org&quot; target=&quot;_blank&quot;&gt;ValidateThis&lt;/a&gt;, 
my validation framework for ColdFusion objects, using &lt;a href=&quot;http://seleniumhq.org/&quot; target=&quot;_blank&quot;&gt;Selenium&lt;/a&gt;. One of the things I wanted to test
were the client-side validations that the framework generates automatically. Selenium makes it very easy to test these, as I can use Selenium&apos;s
&lt;em&gt;assertText&lt;/em&gt; command to locate failure messages that have been generated by the &lt;a href=&quot;http://bassistance.de/jquery-plugins/jquery-plugin-validation/&quot; target=&quot;_blank&quot;&gt;jQuery Validation plugin&lt;/a&gt;,
using XPath, and check whether the message is what I expected.&lt;/p&gt;
&lt;p&gt;I found, however, that I was often getting JavaScript errors when the page first loaded (because I was working on the JS and was introducing errors),
so I was looking for a quick way to add an assert to my test to check whether any JS errors occurred. After some Googling I came to the conclusion that
there is nothing built into Selenium to support this, but there are a number of hacks that can be used to accomplish it. I&apos;m going to describe one of them 
here. Let me state again, for the record, that this is pretty hacky. I&apos;d love to hear from others who may have better solutions.&lt;/p&gt;
&lt;p&gt;I simply add a script to my page that will catch any JS errors by intercepting the &lt;em&gt;window.onerror&lt;/em&gt; event:
&lt;code&gt;&lt;script type=&quot;text/javascript&quot;&gt;
	window.onerror=function(msg){
		$(&quot;body&quot;).attr(&quot;JSError&quot;,msg);
	}
&lt;/script&gt;&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;This will cause an attribute called &lt;em&gt;JSError&lt;/em&gt; with a value corresponding to the JavaScript error message to be added to the &lt;em&gt;body&lt;/em&gt; tag of my document if a JavaScript 
error occurs. Note that I&apos;m using jQuery to do this, so this specific example won&apos;t work if jQuery fails to load. 
Then, in my Selenium test, I just use the command &lt;em&gt;assertElementNotPresent&lt;/em&gt; with a target of &lt;em&gt;//body[@JSError]&lt;/em&gt;.
Now, if any JavaScript errors occur on the page my test will fail and I&apos;ll know I have to address them first. If, for some strange reason, I want to
check for a particular JavaScript error, I could use the &lt;em&gt;assertElementPresent&lt;/em&gt; command with a target of &lt;em&gt;//body[@JSError=&apos;the error message&apos;]&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;Note that I&apos;m using this with a test fixture page, it&apos;s not an actual page that is part of an application. I&apos;m not sure that this would be very
useful in an automated testing environment, I&apos;m just using it for some TDDing, where I want to write an end-to-end acceptance test first, and
then write my unit tests. Getting the test to fail because of a JavaScript error is a nice way, imo, of satisfying the criteria that I must have a 
failing test before writing code to make it work. The usefullness of this technique in terms of pure testing is questionable, but I find it useful 
for my purposes, so I thought I&apos;d put it out there for others.&lt;/p&gt; 
				</description>
				
				<category>TDD</category>				
				
				<category>Selenium</category>				
				
				<pubDate>Mon, 07 Jun 2010 17:54:00 -0400</pubDate>
				<guid>http://www.silverwareconsulting.com/index.cfm/2010/6/7/Checking-for-JavaScript-Errors-with-Selenium</guid>
				
			</item>
			
			<item>
				<title>Some Benefits of Unit Testing</title>
				<link>http://www.silverwareconsulting.com/index.cfm/2008/9/10/Some-Benefits-of-Unit-Testing</link>
				<description>
				
				I must start by saying that, as much as I like option groups, I &lt;em&gt;&lt;strong&gt;love&lt;/strong&gt;&lt;/em&gt; Unit Testing.  I had written previously that &lt;a href=&quot;http://www.silverwareconsulting.com/index.cfm/2008/7/7/I-Like-Unit-Testing&quot;&gt;I Like Unit Testing&lt;/a&gt;, but that brief infatuation has blossomed into a full blown love affair.  I have two people/groups to thank for that, &lt;a href=&quot;http://www.fancybread.com/blog/&quot; target=&quot;_blank&quot;&gt;Paul Marcotte&lt;/a&gt; and &lt;a href=&quot;http://mxunit.org/&quot; target=&quot;_blank&quot;&gt;the MXUnit Team&lt;/a&gt;, who produce an excellent suite of unit testing tools for ColdFusion.&lt;/p&gt;
&lt;p&gt;I met with Paul in the Toronto airport a couple of weeks ago during a brief stopover (his, not mine) and he walked me through his current methodology for unit testing.  He really cleared up some areas of confusion for me, and essentially handed over a set of practices that makes everything oh so easy.  He&apos;s been blogging about his technique in &lt;a href=&quot;http://www.fancybread.com/blog/index.cfm/Test-Driven-Development&quot; target=&quot;_blank&quot;&gt;a series&lt;/a&gt; that I heartily recommend.&lt;/p&gt;
&lt;p&gt;And what can I say about &lt;a href=&quot;http://mxunit.org/&quot; target=&quot;_blank&quot;&gt;MXUnit&lt;/a&gt; that hasn&apos;t already been said?  It totally rocks!  The Eclipse Plugin is da bomb!  If you haven&apos;t checked it out, do so.  Now.  &apos;Nuff said.&lt;/p&gt;
&lt;p&gt;So when do I get to hear about &quot;Some Benefits of Unit Testing&quot;, you may be asking?  Read on.  [More]
				</description>
				
				<category>TDD</category>				
				
				<category>ColdFusion</category>				
				
				<category>MXUnit</category>				
				
				<category>OO Design</category>				
				
				<pubDate>Wed, 10 Sep 2008 06:32:00 -0400</pubDate>
				<guid>http://www.silverwareconsulting.com/index.cfm/2008/9/10/Some-Benefits-of-Unit-Testing</guid>
				
			</item>
			
			<item>
				<title>I Like Unit Testing</title>
				<link>http://www.silverwareconsulting.com/index.cfm/2008/7/7/I-Like-Unit-Testing</link>
				<description>
				
				I never imagined that I&apos;d say those words, but they&apos;re true.  I must start by admitting that I wrote my first unit test a few days ago.  I know, I&apos;m bad, I should have been doing this for years.  I&apos;ve known about unit testing for a long time, I&apos;ve been reading more and more about it, and listening to speakers at conferences extol its virtues.  But somehow I just couldn&apos;t get my a$$ in gear.  It just seemed like too much extra work.  And as a sole developer working on relatively small projects I was able to get away with not doing it.&lt;/p&gt;
&lt;p&gt;Anyway, I read a &lt;a href=&quot;http://www.bryantwebconsulting.com/blog/index.cfm/2008/7/2/An-Introduction-to-Writing-Unit-Tests-with-CFUnit&quot;&gt;blog post&lt;/a&gt; a few days ago that inspired me to take the plunge.  The post describes unit testing with &lt;a href=&quot;http://cfunit.sourceforge.net/&quot;&gt;CFUnit&lt;/a&gt;, but I&apos;d been hearing a lot of good things about &lt;a href=&quot;http://mxunit.org/&quot;&gt;MXUnit&lt;/a&gt;, so I decided to give that a try.&lt;/p&gt;  [More]
				</description>
				
				<category>TDD</category>				
				
				<category>ColdFusion</category>				
				
				<category>MXUnit</category>				
				
				<pubDate>Mon, 07 Jul 2008 06:15:00 -0400</pubDate>
				<guid>http://www.silverwareconsulting.com/index.cfm/2008/7/7/I-Like-Unit-Testing</guid>
				
			</item>
			</channel></rss>