<?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>DEfusion.org.uk &#187; Unit Testing</title>
	<atom:link href="http://www.defusion.org.uk/archives/category/web-development/unit-testing/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.defusion.org.uk</link>
	<description>I too will force my opinions on you</description>
	<lastBuildDate>Mon, 04 Jul 2011 19:28:08 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Testing That An Observer Is Registered In Rails With RSpec</title>
		<link>http://www.defusion.org.uk/archives/2008/07/23/testing-that-an-observer-is-registered-in-rails-with-rspec/</link>
		<comments>http://www.defusion.org.uk/archives/2008/07/23/testing-that-an-observer-is-registered-in-rails-with-rspec/#comments</comments>
		<pubDate>Wed, 23 Jul 2008 14:32:15 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
				<category><![CDATA[RSpec]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Unit Testing]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.defusion.org.uk/archives/2008/07/23/testing-that-an-observer-is-registered-in-rails-with-rspec/</guid>
		<description><![CDATA[I've just started using Observers in a Rails application I'm creating and found out that in order to have them picked up by rails you have to manually register the Observers within your environment.rb file, like so:
Display code as plain text
RUBY:




config.active_record.observers = :my_observer 






I like to have as much coverage for any code I write [...]]]></description>
			<content:encoded><![CDATA[<p>I've just started using <a href="http://api.rubyonrails.com/classes/ActiveRecord/Observer.html">Observers</a> in a Rails application I'm creating and found out that in order to have them picked up by rails you have to manually register the Observers within your environment.rb file, like so:</p>
<div class="igBar"><span id="lruby-4"><a href="#" onclick="javascript:showPlainTxt('ruby-4'); return false;">Display code as plain text</a></span></div>
<div class="syntax_hilite"><span class="langName">RUBY:</span>
<div id="ruby-4">
<div class="ruby">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">config.<span style="color:#9900CC;">active_record</span>.<span style="color:#9900CC;">observers</span> = :my_observer </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>I like to have as much coverage for any code I write in Rails, such as associations I've created, validation rules etc. I'm not testing the validation itself (Rails' tests have that covered) what I'm testing is that I've actually applied the validation rule. </p>
<p>So I figured that I should do the same for the Observers which should be registered. I couldn't find any references to anyone else doing this so after a little bit of digging I've come up with the following approach for use with RSpec:<br />
<span id="more-174"></span></p>
<p>matchers/observer_matchers.rb :</p>
<div class="igBar"><span id="lruby-5"><a href="#" onclick="javascript:showPlainTxt('ruby-5'); return false;">Display code as plain text</a></span></div>
<div class="syntax_hilite"><span class="langName">RUBY:</span>
<div id="ruby-5">
<div class="ruby">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#9966CC; font-weight:bold;">module</span> Matchers</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#9966CC; font-weight:bold;">module</span> ObserverMatchers</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#008000; font-style:italic;">#</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#008000; font-style:italic;"># Used to check that an observer has been registered</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#008000; font-style:italic;">#</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">class</span> BeRegistered</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">def</span> initialize<span style="color:#006600; font-weight:bold;">&#40;</span>observer_name<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; @observer_name = observer_name</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">end</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">def</span> matches?<span style="color:#006600; font-weight:bold;">&#40;</span>observers<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; @observers = observers</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; @observers.<span style="color:#9966CC; font-weight:bold;">include</span>?<span style="color:#006600; font-weight:bold;">&#40;</span>@observer_name<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">end</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">def</span> failure_message</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#996600;">"expected observer with name of '#{@observer_name}' to be registered but wasn't"</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">end</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">def</span> negative_failure_message</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#996600;">"expected observer with name of '#{@observer_name}' not to be registered but was"</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">end</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">end</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#008000; font-style:italic;">#</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#008000; font-style:italic;"># Usage:</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#008000; font-style:italic;">#</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#008000; font-style:italic;"># ActiveRecord::Base.observers.should be_registered(:user_observer)</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">def</span> be_registered<span style="color:#006600; font-weight:bold;">&#40;</span>*args<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; BeRegistered.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#40;</span>*args<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">end</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#9966CC; font-weight:bold;">end</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#9966CC; font-weight:bold;">end</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>models/user_observer_spec.rb</p>
<div class="igBar"><span id="lruby-6"><a href="#" onclick="javascript:showPlainTxt('ruby-6'); return false;">Display code as plain text</a></span></div>
<div class="syntax_hilite"><span class="langName">RUBY:</span>
<div id="ruby-6">
<div class="ruby">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#CC0066; font-weight:bold;">require</span> File.<span style="color:#9900CC;">dirname</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF; font-weight:bold;">__FILE__</span><span style="color:#006600; font-weight:bold;">&#41;</span> + '/../spec_helper'</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">describe UserObserver <span style="color:#9966CC; font-weight:bold;">do</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; it <span style="color:#996600;">"should be registered with the application"</span> <span style="color:#9966CC; font-weight:bold;">do</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; ActiveRecord::Base.<span style="color:#9900CC;">observers</span>.<span style="color:#9900CC;">should</span> be_registered<span style="color:#006600; font-weight:bold;">&#40;</span>:user_observer<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#9966CC; font-weight:bold;">end</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; ...</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#9966CC; font-weight:bold;">end</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>It really is quite simple, but feel free to use the matcher if you want. Consider it released under BSD licence, no guarantees etc.</p>]]></content:encoded>
			<wfw:commentRss>http://www.defusion.org.uk/archives/2008/07/23/testing-that-an-observer-is-registered-in-rails-with-rspec/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Code Update: FlexUnit Custom Test Runner v 0.2.0</title>
		<link>http://www.defusion.org.uk/archives/2008/03/12/code-update-flexunit-custom-test-runner-v-020/</link>
		<comments>http://www.defusion.org.uk/archives/2008/03/12/code-update-flexunit-custom-test-runner-v-020/#comments</comments>
		<pubDate>Wed, 12 Mar 2008 18:35:08 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Unit Testing]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.defusion.org.uk/archives/2008/03/12/code-update-flexunit-custom-test-runner-v-020/</guid>
		<description><![CDATA[I've been doing quite a bit of unit testing on the Flex part of our new product lately and this has led me to fix a few issues and add some improvements to my FlexUnit Test Runner, I've been running with these fixes and improvements for a couple of weeks and finally took some time [...]]]></description>
			<content:encoded><![CDATA[<p>I've been doing quite a bit of unit testing on the Flex part of our new product lately and this has led me to fix a few issues and add some improvements to my <a href="/code/flexunit-custom-test-runner/">FlexUnit Test Runner</a>, I've been running with these fixes and improvements for a couple of weeks and finally took some time out yesterday evening to package them up so I could release them.</p>
<p>The key changes are:</p>
<ul>
<li>Release has two downloads - one compiled to Flex 2.0.1 and one to Flex 3 - as it appears changes to Flex internals meant you couldn't use the Flex 2.0.1 compiled swc in a Flex 3 project.</li>
<li>Fixed: Issue where error thrown when no test results selected.</li>
<li>Fixed: Issue where resizing columns could cause the itemRenderer for the status to display horizontal scrollbar.</li>
<li>Added: Ability to choose whether to display test results live or wait until all tests complete (as displaying them live results in slower execution of tests, as it's constantly updating the UI) - this is saved as a preference.</li>
<li>Added: Ability to toggle display of the class path for the test case - this is saved as a preference.</li>
<li>Added: Test result details now extract Expected &#038; Was from message string for failures and display in a manner that is easier to compare.</li>
<li>Changed: Test details now displayed on change rather than click event, to allow keyboard navigation of test results.</li>
</ul>
<p>Head over to the <a href="/code/flexunit-custom-test-runner/">FlexUnit Test Runner code page</a> for all the downloads and to see the updated demo.</p>]]></content:encoded>
			<wfw:commentRss>http://www.defusion.org.uk/archives/2008/03/12/code-update-flexunit-custom-test-runner-v-020/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>245 tests, 2094 assertions, 0 failures, 0 errors &#8211; yippie!</title>
		<link>http://www.defusion.org.uk/archives/2008/02/27/245-tests-2094-assertions-0-failures-0-errors-yippie/</link>
		<comments>http://www.defusion.org.uk/archives/2008/02/27/245-tests-2094-assertions-0-failures-0-errors-yippie/#comments</comments>
		<pubDate>Wed, 27 Feb 2008 19:37:39 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[My Sites]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Unit Testing]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.defusion.org.uk/archives/2008/02/27/245-tests-2094-assertions-0-failures-0-errors-yippie/</guid>
		<description><![CDATA[Sorry for the rather pointless post, I've just finished ensuring our test coverage is up to scratch on our project (as I mentioned in the last post). This means that I can get on with the next stage.
Which also means we're one step closer to releasing it.
Which also means I'm one step closer to being [...]]]></description>
			<content:encoded><![CDATA[<p>Sorry for the rather pointless post, I've just finished ensuring our test coverage is up to scratch on our project (as I <a href="/archives/2008/02/20/how-i-increased-my-ruby-on-rails-productivity-on-windows/">mentioned in the last post</a>). This means that I can get on with the next stage.</p>
<p>Which also means we're one step closer to releasing it.</p>
<p>Which also means I'm one step closer to being able to tell you all about it, ohhhhh it's so exciting!</p>]]></content:encoded>
			<wfw:commentRss>http://www.defusion.org.uk/archives/2008/02/27/245-tests-2094-assertions-0-failures-0-errors-yippie/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Code: FlexUnit Custom Test Runner</title>
		<link>http://www.defusion.org.uk/archives/2007/10/17/code-flexunit-custom-test-runner/</link>
		<comments>http://www.defusion.org.uk/archives/2007/10/17/code-flexunit-custom-test-runner/#comments</comments>
		<pubDate>Wed, 17 Oct 2007 22:09:32 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Unit Testing]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.defusion.org.uk/archives/2007/10/17/code-flexunit-custom-test-runner/</guid>
		<description><![CDATA[The FlexUnit Custom Test Runner is a customised FlexUnit test runner which aims to improve the presentation and ease of use of running FlexUnit tests.
I have used unit testing in a few different languages, so obviously when I started using Flex I wanted to start off on the right foot by using unit testing from [...]]]></description>
			<content:encoded><![CDATA[<p>The <a href="http://www.defusion.org.uk/code/flexunit-custom-test-runner/">FlexUnit Custom Test Runner</a> is a customised FlexUnit test runner which aims to improve the presentation and ease of use of running <a href="http://code.google.com/p/as3flexunitlib/">FlexUnit</a> tests.</p>
<p>I have used unit testing in a few different languages, so obviously when I started using Flex I wanted to start off on the right foot by using unit testing from the outset. However after a couple of days using the base runner which is provided with FlexUnit I found myself spending a lot more time than I thought I should just looking for the details of the problem in the flex runner.</p>
<p>So as usual I attempted to make something that would work a little better for my requirements, see the <a href="http://www.defusion.org.uk/code/flexunit-custom-test-runner/">FlexUnit Custom Test Runner code page</a> find the full details and the download. As usual any comments should be made on the <a href="http://www.defusion.org.uk/code/flexunit-custom-test-runner/">code page</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.defusion.org.uk/archives/2007/10/17/code-flexunit-custom-test-runner/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Adventures With JavaScript Testing and mootools</title>
		<link>http://www.defusion.org.uk/archives/2006/12/27/adventures-with-javascript-testing-and-mootools/</link>
		<comments>http://www.defusion.org.uk/archives/2006/12/27/adventures-with-javascript-testing-and-mootools/#comments</comments>
		<pubDate>Wed, 27 Dec 2006 17:23:55 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Outer Monologue]]></category>
		<category><![CDATA[Unit Testing]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.defusion.org.uk/archives/2006/12/27/adventures-with-javascript-testing-and-mootools/</guid>
		<description><![CDATA[I'm currently in the middle of writing a reusable little JavaScript utility, which I'll probably release when it's finished, for one of my many projects and I wanted to employ unit testing as part of the development process, as I believe in the benefits of it quite strongly.
However my previous experience with unit testing JavaScript [...]]]></description>
			<content:encoded><![CDATA[<p>I'm currently in the middle of writing a reusable little JavaScript utility, which I'll probably release when it's finished, for one of my many projects and I wanted to employ unit testing as part of the development process, as I believe in the benefits of it quite strongly.</p>
<p>However my previous experience with unit testing JavaScript haven't been the most pleasent, I have tried the most common nUnit variations for JS, the best of which was <a href="http://www.jsunit.net/">JSUnit</a>. But I always found this a little cumbersome and difficult to use, however I had recently <a href="http://mir.aculo.us/2006/9/16/adventures-in-javascript-testing">read about</a> the unit testing available with <a href="http://script.aculo.us/">script.aculo.us</a> and although the only documentation I could find was the <a href="http://mir.aculo.us/2006/9/16/adventures-in-javascript-testing"><acronym title="Portable Document Format">PDF</acronym> available</a> at <a href="http://mir.aculo.us/">mir.aculo.us</a> I thought I'd give it a go.<br />
<span id="more-102"></span><br />
My only worry with using the script.aculo.us unit testing was its dependency on <a href="http://prototype.conio.net/">prototype</a> and <a href="http://script.aculo.us/">script.aculo.us</a> (obviously) and now I've moved across to <a href="http://mootools.net/">mootools</a> for most things I thought there may be some clashes between prototype and mootools for this.</p>
<p>However with the current versions of each of those I managed to get everything working by changing only two lines in the unittest.js:</p>
<div class="igBar"><span id="ljavascript-10"><a href="#" onclick="javascript:showPlainTxt('javascript-10'); return false;">Display code as plain text</a></span></div>
<div class="syntax_hilite"><span class="langName">JavaScript:</span>
<div id="javascript-10">
<div class="javascript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">Event.<span style="color: #006600;">observe</span><span style="color: #66cc66;">&#40;</span>td, <span style="color: #3366CC;">'click'</span>, <span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> ... </div>
</li>
</ol>
</div>
</div>
</div>
<p>
to</p>
<div class="igBar"><span id="ljavascript-11"><a href="#" onclick="javascript:showPlainTxt('javascript-11'); return false;">Display code as plain text</a></span></div>
<div class="syntax_hilite"><span class="langName">JavaScript:</span>
<div id="javascript-11">
<div class="javascript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">$<span style="color: #66cc66;">&#40;</span> td <span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">addEvent</span><span style="color: #66cc66;">&#40;</span> <span style="color: #3366CC;">'click'</span>, <span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> ... </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>The script.aculo.us unit testing framework is very fast (one of my tests performs 16 tests with 1904 assertions in about a second) and it does a great job of catching scripting and syntax errors and presenting those in a useful way without breaking the tests, which some frameworks I've used in different languages don't always handle too well.</p>
<p>The only let down is the current level of <a href="http://wiki.script.aculo.us/scriptaculous/show/UnitTesting">documentation</a>, but if you've looked at unit testing in any other language this is almost the same and you can figure out what most of the assertions do from reading the <acronym title="Portable Document Format">PDF</acronym> and looking at the source. The only minor niggle is the need to use the</p>
<div class="igBar"><span id="ljavascript-12"><a href="#" onclick="javascript:showPlainTxt('javascript-12'); return false;">Display code as plain text</a></span></div>
<div class="syntax_hilite"><span class="langName">JavaScript:</span>
<div id="javascript-12">
<div class="javascript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000066; font-weight: bold;">with</span><span style="color: #66cc66;">&#40;</span> <span style="color: #000066; font-weight: bold;">this</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; ...</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p>
syntax for all your assertions, I haven't found an explanation for why this is needed within each of the test methods and why it can't be hidden from the user, but you need it otherwise it won't work.</p>
<p>I haven't looked at using the <a href="http://wiki.script.aculo.us/scriptaculous/show/FunctionalTesting">functional tests</a> available within script.aculo.us yet as it's still at a very early stage and I'm not sure whether it's needed as I think I can do everything I need right now with unit tests. I hope to write more about specific examples of unit tests, e.g. complex ones which require <acronym title="Document Object Model">DOM</acronym> manipulation or user interaction etc., in JavaScript when I have some decent examples in place.</p>]]></content:encoded>
			<wfw:commentRss>http://www.defusion.org.uk/archives/2006/12/27/adventures-with-javascript-testing-and-mootools/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>PHPUnit2 HTML Runner 0.5.1</title>
		<link>http://www.defusion.org.uk/archives/2006/03/12/phpunit2-html-runner-051/</link>
		<comments>http://www.defusion.org.uk/archives/2006/03/12/phpunit2-html-runner-051/#comments</comments>
		<pubDate>Sun, 12 Mar 2006 22:09:37 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Unit Testing]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.defusion.org.uk/archives/2006/03/12/phpunit2-html-runner-051/</guid>
		<description><![CDATA[Updated the PHPUnit2 HTML Runner to apply a fix provided by Glen Ogilvie for the Formatter when it tries to find the original exception that was thrown.
I also tided the Formatter up a bit by adding much needed comments to explain the functionality it provides in the context of the HTML Runner.

Finally added a new [...]]]></description>
			<content:encoded><![CDATA[<p>Updated the <a href="/code/phpunit2-html-runner/">PHPUnit2 <acronym title="HyperText Markup Language">HTML</acronym> Runner</a> to apply a fix provided by <a href="/code/phpunit2-html-runner/#comment-128">Glen Ogilvie</a> for the Formatter when it tries to find the original exception that was thrown.</p>
<p>I also tided the Formatter up a bit by adding much needed comments to explain the functionality it provides in the context of the <acronym title="HyperText Markup Language">HTML</acronym> Runner.<br />
<span id="more-43"></span><br />
Finally added a new section to the <a href="/code/phpunit2-html-runner/">code page</a> to list known bugs/issues as this is very much a work in progress with very little testing performed I'm sure more will crop up. </p>
<p>Currently there is one issue, also raised by Glen, when the test case/suite is in a different directory to the class definition it is testing <em>and</em> the class definition been tested contains relative includes/requires. Glen also supplied some ideas on how to address this issue but unfortunately I have not had time to look at this, I will hopefully have time to at least begin to replicate the problem within the codebase.</p>
<p>If you find any bugs/issues with the <acronym title="HyperText Markup Language">HTML</acronym> Runner then please either use the <a href="/code/phpunit2-html-runner/#comments">comments</a> or the <a href="/contact/">contact form</a> to report the issue until I sort out a better bug reporting solution.</p>]]></content:encoded>
			<wfw:commentRss>http://www.defusion.org.uk/archives/2006/03/12/phpunit2-html-runner-051/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHPUnit2 GUI HTML Runner</title>
		<link>http://www.defusion.org.uk/archives/2006/02/11/phpunit2-gui-html-runner/</link>
		<comments>http://www.defusion.org.uk/archives/2006/02/11/phpunit2-gui-html-runner/#comments</comments>
		<pubDate>Sat, 11 Feb 2006 00:17:45 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Unit Testing]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.defusion.org.uk/?p=38</guid>
		<description><![CDATA[I've recently started to get into using Test Driven Development in almost everything that I am able to because I've begun to really see and experience the benefits that it brings to development. The basic advantages of TDD are covered very well in an article by Robert Blackburn, Test Driven Development with ColdFusion Part I: [...]]]></description>
			<content:encoded><![CDATA[<p>I've recently started to get into using Test Driven Development in almost everything that I am able to because I've begun to really see and experience the benefits that it brings to development. The basic advantages of <acronym title="Test Driven Development">TDD</acronym> are covered very well in an article by Robert Blackburn, <a href="http://www.fusionauthority.com/Techniques/Article.cfm/ArticleID:4560">Test Driven Development with ColdFusion Part I: An Introduction to Unit Testing</a> so I won't cover them here.</p>
<p>I've been playing around with the <a href="http://www.martinfowler.com/bliki/Xunit.html">xUnit</a> family of testing frameworks in <a href="http://pear.php.net/package/PHPUnit2/"><acronym title="Hypertext PreProcessing">PHP</acronym></a>, <a href="http://www.cfcunit.org/cfcunit/">Coldfusion</a> and <a href="http://www.edwardh.com/jsunit/">JavaScript</a> and really like the way they handle testing. However having been spoilt slightly by CFCUnit and JSUnit with their <acronym title="Hypertext Markup Language"><acronym title="HyperText Markup Language">HTML</acronym></acronym > <acronym title="Graphical User Interface"><acronym title="Graphical User Interface">GUI</acronym></acronym>s I found the text runner in PHPUnit to be lacking for my needs. </p>
<p>So taking inspiration from the interface of CFCUnit I created the <a href="/code/phpunit2-html-runner/">PHPUnit2 <acronym title="HyperText Markup Language">HTML</acronym> Runner</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.defusion.org.uk/archives/2006/02/11/phpunit2-gui-html-runner/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

