<?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>Erik A. Hanson &#187; JsUnit</title>
	<atom:link href="http://www.eahanson.com/category/jsunit/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.eahanson.com</link>
	<description>My weblog</description>
	<lastBuildDate>Mon, 24 May 2010 04:49:46 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>New Test Runner for JsUnit</title>
		<link>http://www.eahanson.com/2008/05/18/new-test-runner-for-jsunit/</link>
		<comments>http://www.eahanson.com/2008/05/18/new-test-runner-for-jsunit/#comments</comments>
		<pubDate>Mon, 19 May 2008 02:01:45 +0000</pubDate>
		<dc:creator>Erik</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[JsUnit]]></category>

		<guid isPermaLink="false">http://www.eahanson.com/2008/05/18/new-test-runner-for-jsunit/</guid>
		<description><![CDATA[Christian Williams created a new test runner for JsUnit. More info here.]]></description>
			<content:encoded><![CDATA[<p>Christian Williams created a new test runner for JsUnit. <a href="http://pivots.pivotallabs.com/users/kelly/blog/articles/450-standup-5-7-2008">More info here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.eahanson.com/2008/05/18/new-test-runner-for-jsunit/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Firing mouse events in tests</title>
		<link>http://www.eahanson.com/2008/01/01/firing-mouse-events-in-tests/</link>
		<comments>http://www.eahanson.com/2008/01/01/firing-mouse-events-in-tests/#comments</comments>
		<pubDate>Wed, 02 Jan 2008 04:17:48 +0000</pubDate>
		<dc:creator>Erik</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[JsUnit]]></category>
		<category><![CDATA[Unit Testing]]></category>
		<category><![CDATA[Web development]]></category>

		<guid isPermaLink="false">http://www.eahanson.com/2008/01/01/firing-mouse-events-in-tests/</guid>
		<description><![CDATA[The Bad News Sending mouse events such as click and mouseover in JsUnit tests can be really hard. More Bad News Prototype doesn&#8217;t make it any easier. Sam Stephenson says: We would very much like to support it in the future. It&#8217;s fairly complicated to implement native event firing across all supported browsers, so in [...]]]></description>
			<content:encoded><![CDATA[<h4>The Bad News</h4>
<p>Sending mouse events such as <code>click</code> and <code>mouseover</code> in <a href="http://jsunit.net">JsUnit</a> tests can be really hard.</p>
<h4>More Bad News</h4>
<p><a href="http://prototypejs.org">Prototype</a> doesn&#8217;t make it any easier. Sam Stephenson <a href="http://groups.google.com/group/prototype-core/browse_thread/thread/9fec287978138250">says</a>:</p>
<blockquote><p>
We would very much like to support it in the future.  It&#8217;s fairly complicated to implement native event firing across all supported browsers, so in 1.6.0, fire works with custom events only.
</p></blockquote>
<h4>YUI To The Rescue</h4>
<p><a href="http://developer.yahoo.com/yui/yuitest/#useractions">YAHOO.util.UserActions</a> can simulate some user actions. Unfortunately, calls to YUI can look a bit clunky in a Prototype-heavy codebase:</p>
<pre>
var element = new Element("div").insert("Hi");
var offset = element.cumulativeOffset();
YAHOO.util.UserAction.click(element, { shiftKey: true });
</pre>
<h4>YUI + Prototype FTW</h4>
<p>A little mixin magic:</p>
<pre>
Element.addMethods({
  simulateClick: YAHOO.util.UserAction.click.bind(YAHOO.util.UserAction),
  simulateDblClick: YAHOO.util.UserAction.dblclick.bind(YAHOO.util.UserAction),
  simulateMousedown: YAHOO.util.UserAction.mousedown.bind(YAHOO.util.UserAction),
  simulateMouseup: YAHOO.util.UserAction.mouseup.bind(YAHOO.util.UserAction),
  simulateMouseover: YAHOO.util.UserAction.mouseover.bind(YAHOO.util.UserAction),
  simulateMouseout: YAHOO.util.UserAction.mouseout.bind(YAHOO.util.UserAction),
  simulateMousemove: YAHOO.util.UserAction.mousemove.bind(YAHOO.util.UserAction)
});
</pre>
<p>and now our test code looks nicer:</p>
<pre>
var element = new Element("div").insert("Hi");
var offset = element.cumulativeOffset();
myElement.simulateClick({ shiftKey: true });
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.eahanson.com/2008/01/01/firing-mouse-events-in-tests/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Big New Feature In JsUnit 2.2 alpha 25</title>
		<link>http://www.eahanson.com/2007/08/13/big-new-feature-in-jsunit-22-alpha-25/</link>
		<comments>http://www.eahanson.com/2007/08/13/big-new-feature-in-jsunit-22-alpha-25/#comments</comments>
		<pubDate>Mon, 13 Aug 2007 08:21:33 +0000</pubDate>
		<dc:creator>Erik</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[JsUnit]]></category>
		<category><![CDATA[Unit Testing]]></category>

		<guid isPermaLink="false">http://www.eahanson.com/2007/08/13/big-new-feature-in-jsunit-22-alpha-25/</guid>
		<description><![CDATA[In order to run all test functions in a test page, JsUnit naturally needs to know what those test functions are. It's able to get a list of those functions from Firefox, Safari and Opera, but it's not able to get them from Internet Explorer. So in IE, JsUnit has to resort to searching the text of all scripts for strings that look like test function names. Unfortunately, it doesn't understand comments so commented-out test functions will end up running anyway. ]]></description>
			<content:encoded><![CDATA[<p>In order to run all test functions in a test page, <a href="http://www.jsunit.net/">JsUnit</a> naturally needs to know what those test functions are. It&#8217;s able to get a list of those functions from Firefox, Safari and Opera, but it&#8217;s not able to get them from Internet Explorer. </p>
<p>So in IE, JsUnit has to resort to searching the text of all scripts for strings that look like test function names. Unfortunately, it doesn&#8217;t understand comments so commented-out test functions will end up running anyway. </p>
<p>Recently, Dean McNamee and <a href="http://pupius.co.uk/">Dan Pupius</a> alerted <a href="http://edwardh.com/">Edward Hieatt</a> and me to an undocumented Internet Explorer Javascript function called <tt>RuntimeObject</tt> and suggested JsUnit might be able to use it to discover test functions. </p>
<p>I replaced the text searching with <tt>RuntimeObject</tt> and tagged it as version 2.2 alpha 25. (I also added an <tt>assertEqualsIgnoringOrder</tt> function while I was making changes.)</p>
<p>Browse the new version <a href="http://jsunit.svn.sourceforge.net/viewvc/jsunit/tags/v2_2alpha25/jsunit/">at SourceForge</a> or check it out like this:</p>
<div class="code">svn co https://jsunit.svn.sf.net/svnroot/jsunit/tags/v2_2alpha25/jsunit/ jsunit</div>
<p>Try it out and <a href="http://tech.groups.yahoo.com/group/jsunit/">let us know</a> if there are any problems.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.eahanson.com/2007/08/13/big-new-feature-in-jsunit-22-alpha-25/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Minor New Features In JsUnit 2.2alpha24</title>
		<link>http://www.eahanson.com/2007/08/09/minor-new-features-in-jsunit-22alpha24/</link>
		<comments>http://www.eahanson.com/2007/08/09/minor-new-features-in-jsunit-22alpha24/#comments</comments>
		<pubDate>Fri, 10 Aug 2007 01:46:36 +0000</pubDate>
		<dc:creator>Erik</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[JsUnit]]></category>
		<category><![CDATA[Unit Testing]]></category>

		<guid isPermaLink="false">http://www.eahanson.com/2007/08/09/minor-new-features-in-jsunit-22alpha24/</guid>
		<description><![CDATA[I added a few new features to JsUnit and tagged it as version 2.2 alpha 24: new log button, new URL parameters, and easier suite creation.]]></description>
			<content:encoded><![CDATA[<p>I added a few new features to <a href="http://jsunit.net">JsUnit</a> and tagged it as version 2.2 alpha 24. Browse the new version <a href="http://jsunit.svn.sourceforge.net/viewvc/jsunit/tags/v2_2alpha24/jsunit/">at SourceForge</a> or check it out like this:</p>
<div class="code">
  svn co https://jsunit.svn.sf.net/svnroot/jsunit/tags/v2_2alpha24/jsunit/ jsunit
</div>
<h3>Show Log</h3>
<p>There&#8217;s now a &#8220;Show Log&#8221; button that opens a window with a log of what JsUnit has been up to.</p>
<p><a href="http://www.eahanson.com/weblog/wp-content/uploads/2007/08/testrunner.jpg" title="New Log Button"><img src="http://www.eahanson.com/weblog/wp-content/uploads/2007/08/testrunner.thumbnail.jpg" alt="New Log Button" /></a></p>
<p>New log button (click image for larger view)</p>
<p><a href="http://www.eahanson.com/weblog/wp-content/uploads/2007/08/log.gif" title="New Log Window"><img src="http://www.eahanson.com/weblog/wp-content/uploads/2007/08/log.thumbnail.gif" alt="New Log Window" /></a></p>
<p>New log window (click image for larger view)</p>
<h3>New URL Parameters</h3>
<p>There are three new URL parameters:</p>
<ul>
<li><tt>suppressDialogs=true</tt> will suppress JsUnit&#8217;s dialogs in interactive mode</li>
<li><tt>setupPageTimeout=<em>n</em></tt> will change the timeout for the setupPage call</li>
<li><tt>pageLoadTimeout=<em>n</em></tt> will change the page load timeout</li>
</ul>
<h3>Easier Suite Creation</h3>
<p>The <tt>jsUnitTestSuite</tt> constructor now accepts test pages and subsuites as parameters. So instead of this:</p>
<pre>
function suite() {
  var suite = new jsUnitTestSuite();
  suite.addTestPage("/foo/barTest.html");
  suite.addTestPage("/foo/bazTest.html");
  return suite;
}</pre>
<p>you can do this:</p>
<pre>
function suite() {
  return new jsUnitTestSuite("/foo/barTest.html", "/foo/bazTest.html");
}</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.eahanson.com/2007/08/09/minor-new-features-in-jsunit-22alpha24/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A Ruby Script To Generate a JsUnit Suite</title>
		<link>http://www.eahanson.com/2007/05/26/a-ruby-script-to-generate-a-jsunit-suite/</link>
		<comments>http://www.eahanson.com/2007/05/26/a-ruby-script-to-generate-a-jsunit-suite/#comments</comments>
		<pubDate>Sat, 26 May 2007 20:38:29 +0000</pubDate>
		<dc:creator>Erik</dc:creator>
				<category><![CDATA[Howto]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[JsUnit]]></category>

		<guid isPermaLink="false">http://www.eahanson.com/weblog/?p=16</guid>
		<description><![CDATA[I've got a bunch of JsUnit tests for a project I'm working on and I wanted an easy way to create a JsUnit suite that can run all the tests but also run any individual test page. Also, I wanted to be able to view any test page so I could debug the tests with Firebug. I also didn't want to run a web server all the time, so I wanted a script that would create a static HTML file.]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve got a bunch of JsUnit tests for a project I&#8217;m working on and I wanted an easy way to create a JsUnit suite that can run all the tests but also run any individual test page.</p>
<p>Also, I wanted to be able to view any test page so I could debug the tests with Firebug (as explained <a href="http://www.eahanson.com/weblog/?p=11">here</a>).</p>
<p>I also didn&#8217;t want to run a web server all the time, so I wanted a script that would create a static HTML file.</p>
<p>Here&#8217;s what I came up with. It&#8217;s not configurable, so you&#8217;ll have to modify it for your own needs.</p>
<p align="center"><strong><a href="/code/JsUnitSuiteBuilder.rb">JsUnitSuiteBuilder.rb</a></strong></p>
]]></content:encoded>
			<wfw:commentRss>http://www.eahanson.com/2007/05/26/a-ruby-script-to-generate-a-jsunit-suite/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Debugging a JsUnit Test With Firebug</title>
		<link>http://www.eahanson.com/2006/11/16/debugging-a-jsunit-test-with-firebug/</link>
		<comments>http://www.eahanson.com/2006/11/16/debugging-a-jsunit-test-with-firebug/#comments</comments>
		<pubDate>Thu, 16 Nov 2006 07:36:53 +0000</pubDate>
		<dc:creator>Erik</dc:creator>
				<category><![CDATA[Howto]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[JsUnit]]></category>

		<guid isPermaLink="false">http://www.eahanson.com/weblog/?p=11</guid>
		<description><![CDATA[Sometimes I find that I want to debug a JsUnit test because I'm not quite sure what's going on in the browser. FireBug has a nice debugger, but I couldn't get it to work with the JsUnit test runner. I could set breakpoints in JsUnit itself, but any breakpoints in my test would be ignored. And then it hit me: ditch the test runner.]]></description>
			<content:encoded><![CDATA[<p>Sometimes I find that I want to debug a <a href="http://www.jsunit.net/">JsUnit</a> test because I&#8217;m not quite sure what&#8217;s going on in the browser.</p>
<p><a href="http://getfirebug.com/">FireBug</a> has a nice debugger, but I couldn&#8217;t get it to work with the JsUnit test runner. I could set breakpoints in JsUnit itself, but any breakpoints in my test would be ignored.</p>
<p>And then it hit me: ditch the test runner. I opened my test page directly in Firefox, opened FireBug, clicked the Debugger tab, and chose my test from the &#8220;Scripts&#8221; menu. Here&#8217;s a simplified version:</p>
<pre>
function testUpdate() {
  var listPanel = new ListPanel();
  listPanel.update(["one", "two", "three"]);

  var children = $("content").childNodes;
  assertEquals("one", children[0]);
  assertEquals("two", children[1]);
  assertEquals("three", children[2]);
}</pre>
<p>I put a breakpoint at the first <tt>assertEquals</tt> and switched to the Console tab and typed <tt>testUpdate()</tt>. I saw the ListPanel getting drawn in the browser (something you don&#8217;t see in the JsUnit test runner) and in the Debugger tab I could inspect all my variables.</p>
<p>But even better, I could go back to the Console tab and start evaluating Javascript.</p>
<pre>
&gt;&gt;&gt; children.length
3</pre>
<p>Good.</p>
<pre>
&gt;&gt;&gt; children[0]
div</pre>
<p>Bad.</p>
<pre>
&gt;&gt;&gt; children[0].firstChild
[Text] "one"</pre>
<p>Better.</p>
<pre>
&gt;&gt;&gt; children[0].firstChild.nodeValue
"one"</pre>
<p>Perfect.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.eahanson.com/2006/11/16/debugging-a-jsunit-test-with-firebug/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
