<?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>FUnit Testing Framework</title>
	<atom:link href="http://blog.funit.org/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://blog.funit.org</link>
	<description>Metadata Driven Unit Testing for Flex</description>
	<lastBuildDate>Wed, 08 Jul 2009 17:45:41 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Capturing Test Results in FUnit</title>
		<link>http://blog.funit.org/?p=327</link>
		<comments>http://blog.funit.org/?p=327#comments</comments>
		<pubDate>Tue, 19 May 2009 12:22:20 +0000</pubDate>
		<dc:creator>Ryan Christiansen</dc:creator>
				<category><![CDATA[Debug Console]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Graphical Interface]]></category>
		<category><![CDATA[Test Runners]]></category>
		<category><![CDATA[automation]]></category>
		<category><![CDATA[debug]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[funit]]></category>
		<category><![CDATA[unit-testing]]></category>

		<guid isPermaLink="false">http://blog.funit.org/?p=327</guid>
		<description><![CDATA[I have received several inquiries regarding the SimpleTestRunner and a means of visualizing test failures. It is important to note that the current SimpleTestRunner GUI is really intended for automation purposes. A full GUI similar to what you&#8217;d find in FlexUnit or Fluint, is on the roadmap. It&#8217;s just not ready yet. In the meantime, [...]]]></description>
			<content:encoded><![CDATA[<p>I have received several inquiries regarding the <em>SimpleTestRunner</em> and a means of visualizing test failures. It is important to note that the current <em>SimpleTestRunner</em> GUI is really intended for automation purposes. A full GUI similar to what you&#8217;d find in FlexUnit or Fluint, is on the roadmap. It&#8217;s just not ready yet.</p>
<p>In the meantime, there are several options for recording test results.</p>
<h4><span style="color: #333399;">Option 1:</span></h4>
<p>The most longstanding option is the DebugTestListener. Just run the following&#8230;</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #6699cc; font-weight: bold;">var</span> runner<span style="color: #000000; font-weight: bold;">:</span>TestRunner = <span style="color: #0033ff; font-weight: bold;">new</span> TestRunner<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
runner.<span style="color: #004993;">test</span> = LibraryTestSuite.getInstance<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
runner.run<span style="color: #000000;">&#40;</span> <span style="color: #0033ff; font-weight: bold;">new</span> DebugTestListener<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#41;</span>;</pre></div></div>

<p><span style="color: #BB0000;"><strong>Note:</strong> This <strong>must</strong> be run in <em>debug</em> mode.</span><br />
You will see the following in the debug console.<br />
<em>(I&#8217;ve intentionally introduced some errors so you see the output)</em></p>

<div class="wp_syntax"><div class="code"><pre class="none" style="font-family:monospace;">------------------------------------------------------------------
FUnit Framework - Flex Unit Testing Environment
Framework Version: 0.72.0452 (Build 1106)
&nbsp;
Adobe Windows (StandAlone)
Player Version: WIN 9,0,124,0
------------------------------------------------------------------
&nbsp;
################################ UNIT TESTS ################################
Running tests in ''...
***** funit.framework::ArrayAssertTests.isNotSubsetOf
***** funit.framework::ArrayAssertTests.doesNotContain
***** funit.framework::ArrayAssertTests.containsFailureOnEmpty
***** funit.framework::ArrayAssertTests.areNotEqualHandlesNull
***** funit.framework::ArrayAssertTests.isNotEmpty
&nbsp;
[continued ...]
&nbsp;
############################################################################
############## F A I L U R E S #################
1) funit.framework::ArrayAssertTests.itemsOfTypeFailure :
  Expected: all items instance of &lt;String&gt;
  But was: [ &quot;x&quot;, &quot;y&quot;, &lt;Object&gt; ]
     at funit.framework::CollectionAssert$/allItemsAreInstancesOf()[..\Framework\main\source\funit\framework\CollectionAssert.as:82]
     at funit.framework::ArrayAssertTests/itemsOfTypeFailure()[..\Framework\tests\source\funit\framework\ArrayAssertTests.as:59]
     at Function/http://adobe.com/AS3/2006/builtin::apply()
     at InternalMethodInfo/invoke()[..\SwirlyVision\Corelib\main\source\sv\reflection\InternalMethodInfo.as:96]
     at funit.core::TestMethod/invokeTestCase()[..\Framework\main\source\funit\core\TestMethod.as:127]
     at funit.core::TestMethod/runTestCaseImpl()[..\Framework\main\source\funit\core\TestMethod.as:105]
     at funit.core::TestMethod/runTestCase()[..\Framework\main\source\funit\core\TestMethod.as:82]
     at funit.core::TestCase/run()[..\Framework\main\source\funit\core\TestCase.as:56]
     at funit.core::TestSuite/runTest()[..\Framework\main\source\funit\core\TestSuite.as:243]
     at &lt;anonymous&gt;()[..\Framework\main\source\funit\core\TestSuite.as:180]
     at flash.events::EventDispatcher/dispatchEventFunction()
     at flash.events::EventDispatcher/dispatchEvent()
     at funit.core::TestScheduler/scheduleTest()[..\Framework\main\source\funit\core\TestScheduler.as:128]
     at &lt;anonymous&gt;()[..\Framework\main\source\funit\core\TestScheduler.as:105]
     at flash.events::EventDispatcher/dispatchEventFunction()
     at flash.events::EventDispatcher/dispatchEvent()
     at flash.utils::Timer/tick()
2) funit.framework::ArrayAssertTests.itemsUniqueFailure :
  Expected: all items unique
  But was: [ &quot;x&quot;, &quot;y&quot;, &quot;x&quot; ]
     at funit.framework::CollectionAssert$/allItemsAreUnique()[..\Framework\main\source\funit\framework\CollectionAssert.as:124]
     at funit.framework::ArrayAssertTests/itemsUniqueFailure()[..\Framework\tests\source\funit\framework\ArrayAssertTests.as:115]
     at Function/http://adobe.com/AS3/2006/builtin::apply()
     at InternalMethodInfo/invoke()[..\SwirlyVision\Corelib\main\source\sv\reflection\InternalMethodInfo.as:96]
     at funit.core::TestMethod/invokeTestCase()[..\Framework\main\source\funit\core\TestMethod.as:127]
     at funit.core::TestMethod/runTestCaseImpl()[..\Framework\main\source\funit\core\TestMethod.as:105]
     at funit.core::TestMethod/runTestCase()[..\Framework\main\source\funit\core\TestMethod.as:82]
     at funit.core::TestCase/run()[..\Framework\main\source\funit\core\TestCase.as:56]
     at funit.core::TestSuite/runTest()[..\Framework\main\source\funit\core\TestSuite.as:243]
     at &lt;anonymous&gt;()[..\Framework\main\source\funit\core\TestSuite.as:180]
     at flash.events::EventDispatcher/dispatchEventFunction()
     at flash.events::EventDispatcher/dispatchEvent()
     at funit.core::TestScheduler/scheduleTest()[..\Framework\main\source\funit\core\TestScheduler.as:128]
     at &lt;anonymous&gt;()[..\Framework\main\source\funit\core\TestScheduler.as:105]
     at flash.events::EventDispatcher/dispatchEventFunction()
     at flash.events::EventDispatcher/dispatchEvent()
     at flash.utils::Timer/tick()
############################################################################
Executed tests : 160
Ignored tests : 1
Failed tests : 2
Unhandled exceptions : 0
Total time : 1.231 seconds
############################################################################</pre></div></div>

<h4><span style="color: #333399;">Option 2:</span></h4>
<p>The XmlResultWriter will take an TestResult object and translate it into an NUnit-style xml schema. If you choose, you can simply trace the result to the debug console or write it to a flat file with Adobe AIR.</p>
<p>If you want to get a little more fancy can use this in combination with ANT and write this out to an xml file. Unlike other approaches, this does not require use of either the AIR runtime or XMLSocket connections. Instead, you need only target the standalone debug player distributed with the Flex SDK. This approach is ideal for with automated build integration, especially those with test report generation.</p>
<p>Here&#8217;s how you might set up your test runner&#8230;</p>

<div class="wp_syntax"><div class="code"><pre class="mxml" style="font-family:monospace;"><span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Application</span> xmlns:mx=<span style="color: #ff0000;">&quot;http://www.adobe.com/2006/mxml&quot;</span></span>
<span style="color: #000000;">                xmlns:funit=<span style="color: #ff0000;">&quot;http://www.funit.org/2007/mxml&quot;</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
    <span style="color: #339933;">&lt;mx:Script&gt;</span>
<span style="color: #339933;">        &lt;![CDATA[</span>
&nbsp;
<span style="color: #339933;">            import mx.utils.StringUtil;</span>
&nbsp;
<span style="color: #339933;">            import funit.LibraryTestSuite;</span>
<span style="color: #339933;">            import funit.listeners.events.RunFinishEvent;</span>
<span style="color: #339933;">            import funit.utils.XmlResultWriter;</span>
&nbsp;
<span style="color: #339933;">            private function runTests() : void</span>
<span style="color: #339933;">            {</span>
<span style="color: #339933;">                runner.addEventListener(</span>
<span style="color: #339933;">                    RunFinishEvent.RUN_FINISH,</span>
<span style="color: #339933;">                    runFinishedHandler</span>
<span style="color: #339933;">                );</span>
<span style="color: #339933;">                runner.run();</span>
<span style="color: #339933;">            }</span>
&nbsp;
<span style="color: #339933;">            private function runFinishedHandler( event:RunFinishEvent ) : void</span>
<span style="color: #339933;">            {</span>
<span style="color: #339933;">                var writer:XmlResultWriter =</span>
<span style="color: #339933;">                    new XmlResultWriter(event.result);</span>
&nbsp;
<span style="color: #339933;">                var result:String =</span>
<span style="color: #339933;">                    &quot;&lt;?xml version=\&quot;1.0\&quot; encoding=\&quot;utf-8\&quot;?&gt;\n&quot; +</span>
<span style="color: #339933;">                    writer.result.toXMLString();</span>
&nbsp;
<span style="color: #339933;">                trace( StringUtil.substitute(&quot;##funit\[TestResult {0}]##&quot;, result) );</span>
<span style="color: #339933;">            }</span>
<span style="color: #339933;">        ]]&gt;</span>
<span style="color: #339933;">    &lt;/mx:Script&gt;</span>
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:creationComplete</span><span style="color: #7400FF;">&gt;</span></span>runTests();<span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:creationComplete</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;funit:AutomationTestRunner</span> id=<span style="color: #ff0000;">&quot;runner&quot;</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;funit:test</span><span style="color: #7400FF;">&gt;</span></span>{LibraryTestSuite.getInstance()}<span style="color: #000000;"><span style="color: #7400FF;">&lt;/funit:test</span><span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/funit:AutomationTestRunner</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:Application</span><span style="color: #7400FF;">&gt;</span></span></pre></div></div>

<p>Believe it or not, the ANT side is just as easy.<br />
<em>(Properties are used for clarity and reuse)</em></p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">&lt;!--</span>
<span style="color: #808080; font-style: italic;">    Execute Tests</span>
<span style="color: #808080; font-style: italic;">--&gt;</span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;target</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;test&quot;</span> <span style="color: #000066;">description</span>=<span style="color: #ff0000;">&quot;Test All&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;exec</span> <span style="color: #000066;">executable</span>=<span style="color: #ff0000;">&quot;${flashplayer.debug.exe}&quot;</span> <span style="color: #000066;">errorproperty</span>=<span style="color: #ff0000;">&quot;trace.output&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;arg</span> <span style="color: #000066;">line</span>=<span style="color: #ff0000;">&quot;${bin.debug.dir}/FUnitTestRunner.swf&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;redirector<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;errorfilterchain<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ignoreblank</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/errorfilterchain<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/redirector<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/exec<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
    <span style="color: #808080; font-style: italic;">&lt;!-- Extract results and write TestResult.xml --&gt;</span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;echo</span> <span style="color: #000066;">file</span>=<span style="color: #ff0000;">&quot;${bin.debug.dir}/TestResult.xml&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>${trace.output}<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/echo<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;replaceregexp</span> <span style="color: #000066;">file</span>=<span style="color: #ff0000;">&quot;${bin.debug.dir}/TestResult.xml&quot;</span> <span style="color: #000066;">match</span>=<span style="color: #ff0000;">&quot;(?s).*##funit\[TestResult (.+)\]##&quot;</span> <span style="color: #000066;">replace</span>=<span style="color: #ff0000;">&quot;\1&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
    <span style="color: #808080; font-style: italic;">&lt;!-- Display original trace statements --&gt;</span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;echo<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>${trace.output}<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/echo<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/target<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>The <strong><ignoreblank /></strong> in the redirector is necessary to prevent double line spacing. I&#8217;m not sure why this happens but it helps keep our final output pretty.</p>
<p>The regular expression helps ensure that only the result xml is written to the final file. Without it, any other trace calls would be written as well, causing invalid xml markup.</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span>StringUtil.substitute<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;##funit<span style="">\[</span>TestResult {0}]##&quot;</span>, result<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;</pre></div></div>

<p>To avoid this, I&#8217;ve wrapped the result in a unique closure. Simply put, only the value of result would make it into TestResult.xml.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.funit.org/?feed=rss2&amp;p=327</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>FUnit Framework Update 0.70.0383</title>
		<link>http://blog.funit.org/?p=268</link>
		<comments>http://blog.funit.org/?p=268#comments</comments>
		<pubDate>Mon, 16 Feb 2009 06:03:41 +0000</pubDate>
		<dc:creator>Ryan Christiansen</dc:creator>
				<category><![CDATA[Updates]]></category>
		<category><![CDATA[automation]]></category>
		<category><![CDATA[continuous-integration]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[funit]]></category>
		<category><![CDATA[teamcity]]></category>
		<category><![CDATA[unit-testing]]></category>

		<guid isPermaLink="false">http://blog.funit.org/?p=268</guid>
		<description><![CDATA[The next major revision to the framework core is now available for download. Release 0.70 provides significant enhancements in three key areas: GUI Support Test Automation Automated Builds and Continuous Integration GUI Test Runner Although a forthcoming enhanced UI was detailed in the framework roadmap, community feedback indicated that a GUI was critical, even in [...]]]></description>
			<content:encoded><![CDATA[<p>The next major revision to the framework core is now available for download. Release 0.70 provides significant enhancements in three key areas:</p>
<ul>
<li>GUI Support</li>
<li>Test Automation</li>
<li>Automated Builds and Continuous Integration</li>
</ul>
<h4><span style="color: #333399;">GUI Test Runner</span></h4>
<p>Although a forthcoming enhanced UI was detailed in the framework <a title="FUnit Development Roadmap" href="http://blog.funit.org/?p=10" target="_blank">roadmap</a>, community feedback indicated that a GUI was critical, even in the earliest development stages. I had admittedly focused more on the NUnit feature set, rather than front-end usability. Not surprisingly, certain aspects of a .NET approach stifled the strengths of the Flash environment making GUI development cumbersome at best. This release addressed several of these limitations.</p>
<p>The <em>SimpleTestRunner</em> was designed for use with automated testing where visual feedback is useful but little interactivity is required.</p>

    <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="swfobj_0" width="478" height="280">
      <param name="movie" value="http://teamcity.swirlyvision.net/repository/download/bt6/713:id/FUnitProject/FUnitTestRunner.swf?guest=1" />
      <!--[if !IE]>-->
      <object type="application/x-shockwave-flash" data="http://teamcity.swirlyvision.net/repository/download/bt6/713:id/FUnitProject/FUnitTestRunner.swf?guest=1" width="478" height="280">
      <!--<![endif]-->
        <p>The Flash plugin is required to view this object.</p>
      <!--[if !IE]>-->
      </object>
      <!--<![endif]-->
    </object>

<p>A more advanced testing interface, such as the FlexUnit GUI shown <a href="http://teamcity.swirlyvision.net/repository/download/bt6/713:id/FUnitProject/FlexUnitTestRunner.swf?guest=1" target="_blank">here</a>, is actively underway.</p>
<h4><span style="color: #333399;">Continuous Integration Support for TeamCity</span></h4>
<p>On of the most exciting aspects of Release 0.70 is that the build was fully automated start to finish. That means that the SVN checkout, ANT builds, FUnit testing with results, and final zipped distributions were all done automatically by my TeamCity build server.</p>
<p><img alt="FUnit Tests in TeamCity" src="wp-content/images/FUnit_Framework_Update_0.70.0383/FUnit_Tests_in_TeamCity.jpg" title="FUnit Tests in TeamCity" width="478" height="350" /></p>
<p>It is important to note that TeamCity is not just running the tests, it is ingesting live data and displays detailed information about test results and failures as they occur. Click <a href="http://teamcity.swirlyvision.net/viewLog.html?buildId=714&#038;buildTypeId=bt5&#038;tab=testsInfo&#038;guest=1" target="_blank">here</a> to have a closer look.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.funit.org/?feed=rss2&amp;p=268</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Continuous Integration with FUnit and TeamCity</title>
		<link>http://blog.funit.org/?p=185</link>
		<comments>http://blog.funit.org/?p=185#comments</comments>
		<pubDate>Mon, 19 Jan 2009 05:55:09 +0000</pubDate>
		<dc:creator>Ryan Christiansen</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[automation]]></category>
		<category><![CDATA[Community]]></category>
		<category><![CDATA[continuous-integration]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[funit]]></category>
		<category><![CDATA[unit-testing]]></category>

		<guid isPermaLink="false">http://blog.funit.org/?p=185</guid>
		<description><![CDATA[I&#8217;m sure many of you are familiar with what it means to eat your own dog food. Put simply, and you can quote me&#8230; Any developer that won&#8217;t use his own project shouldn&#8217;t be surprised when no one else will either. With that said, I do my best to apply FUnit and it&#8217;s support libraries [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m sure many of you are familiar with what it means to <em><a href="http://en.wikipedia.org/wiki/Eat_one%27s_own_dog_food">eat your own dog food</a></em>. Put simply, and you can quote me&#8230;</p>
<blockquote><p><em>Any developer that won&#8217;t use his own project shouldn&#8217;t be surprised when no one else will either.</em></p></blockquote>
<p>With that said, I do my best to apply FUnit and it&#8217;s support libraries wherever possible. This has resulted in direct improvements to code quality, user experience, and extensibility. Here are just a few ways this approach has helped already:</p>
<ul>
<li>Find bugs earlier in the deployment cycle.</li>
<li>Identify confusing or weak areas of usability.</li>
<li>Remove unnecessary or redundant APIs.</li>
</ul>
<h4><span style="color: #333399;">Build Automation &#8211; Just to Name A Few&#8230;</span></h4>
<p>Over the past couple weeks, I have improved support for third-party build management tools such as <a title="TeamCity: Distributed Build Management and Continuous Integration Server" href="http://www.jetbrains.com/teamcity" target="_blank">TeamCity</a>, <a title="Cruise: Continuous Integration and Release Management" href="http://studios.thoughtworks.com/cruise-continuous-integration" target="_blank">Cruise</a>, and <a title="Maven: Software Project Management and Comprehension Tool" href="http://maven.apache.org/" target="_blank">Maven</a>. Although TeamCity and Cruise (the makers of the open-source project <a title="CruiseControl: Continuous Integration Tool and Extensible Build Framework" href="http://cruisecontrol.sourceforge.net/" target="_blank">CruiseControl</a>) are commercial products, both provide very powerful free editions as well. Maven on the other hand is fully open-source and is gaining momentum in the development community.</p>
<h4><span style="color: #333399;">Commercial vs. Open Source</span></h4>
<p>Being less experienced in automation and server technologies, I&#8217;m a perfect test subject for ease of use. I could probably write an entire article on the semantics of free vs. commercial software so I&#8217;ll keep it brief.</p>
<p>So do I prefer commercial or open source? well both&#8230; it depends. Solutions are not better just because they&#8217;re free any more than commercial products are better because of financial backing. There are plenty of examples of all cases. <a title="Subversion: An Open Source Version Control System" href="http://subversion.tigris.org/" target="_blank">Subversion</a> and <a title="TortoiseSVN: The Coolest Interface to (Sub)Version Control" href="http://tortoisesvn.tigris.org/" target="_blank">TortoiseSVN</a> are a great examples of a successful open source projects that i love. <a title="The Industry Standard for Windows Installations" href="http://www.installshield.com/" target="_blank">InstallShield</a> on the other hand is an expensive, bloated, metastasized ball of corrosive goo that has managed to break the simplest (previously working) installers without changing a single line of code &#8230; but I digress &#8230; rant.close();</p>
<h4><span style="color: #333399;">Choosing a Continuous Integration Server</span></h4>
<p>My first instinct was to try <a title="Maven: Software Project Management and Comprehension Tool" href="http://maven.apache.org/" target="_blank">Maven</a>. I wanted to choose something I felt the community would already be using. Unfortunately, not having used it before, I found Maven difficult to pick up despite relatively good documentation and community examples. It is important to note, however, that there is great progress being made in this arena for Flex development with projects like <a title="flex-mojos: A Collection of Maven Plugins to Compile, Optimize, and Test Flex Projects" href="http://code.google.com/p/flex-mojos/" target="_blank">flex-mojos</a>. Therefore, I will be revisiting Maven in the future to ensure it is supported properly.</p>
<p>There are two specific things made me favor <a title="TeamCity: Distributed Build Management and Continuous Integration Server" href="http://www.jetbrains.com/teamcity" target="_blank">TeamCity</a> and <a title="Cruise: Continuous Integration and Release Management" href="http://studios.thoughtworks.com/cruise-continuous-integration" target="_blank">Cruise</a> over Maven.</p>
<ul>
<li>Once installed it <em>just works</em> with no additional configuration.</li>
<li>The web interface made management of build scripts simple and intuitive.</li>
</ul>
<p>But the real deal-maker for <a title="TeamCity: Distributed Build Management and Continuous Integration Server" href="http://www.jetbrains.com/teamcity" target="_blank">TeamCity</a> was something called <a title="Remote Run and Pre-Tested Commit" href="http://www.jetbrains.com/teamcity/features/continuous_integration.html#Remote_Build_Run_and_Pre-Tested_Commit" target="_blank">Remote Run</a>. Remote Run allows developers to trigger personal builds of local changes directly from their development IDE (Eclipse, VisualStudio, or IntelliJ IDEA). Here&#8217;s the best part, you don&#8217;t have to commit your changes to version control to run your build remotely. How cool is that?</p>
<p>This may not seem like a big deal when you&#8217;re talking about smaller project you can test locally. But it is a big deal for complex builds that require automation to be tested. What if you need to modify the build scripts? What if you change your build dependencies? What if you have multiple developers on the project? If you break the build in SVN, you hurt progress for everybody.</p>
<p>You don&#8217;t want to commit something unless you know it works. For this there is a second feature to Remote Run called <a title="Pre-Tested Commit" href="http://www.jetbrains.com/teamcity/delayed_commit.html" target="_blank">Pre-Tested Commit</a>. This will automatically commit your selected changes if and only if they can be build successfully on the server.</p>
<p>Yeah&#8230; I like TeamCity&#8230; a lot.</p>
<h4><span style="color: #333399;">And the winner is&#8230; TeamCity</span></h4>
<p>You can log in as a guest to my project&#8217;s build automation and deployment server below or from the community links in the sidebar.</p>
<p><span style="color: #333399;"><strong>Login here:</strong> <a title="FUnit Build Automation Dashboard" href="http://teamcity.swirlyvision.net/" target="_blank">FUnit Build Automation Dashboard</a></span></p>
<p>You will have access to build <em>Artifacts</em> and FUnit test statistics. This includes compiled binary, asdocs, distributions, source files, and nightly builds. Just in case you missed it, yes FUnit is fully integrated and maintains detailed UI records of all executed tests.</p>
<p><span style="color: #BB0000;"><strong>Note:</strong> The TeamCity server instance is currently hosted by my development machine from home. Until I can buy a second dedicated box and somehow acquire a legal copy of Windows Server 2003 R2 or 2008, I can&#8217;t guarantee it&#8217;s reliability. Although TeamCity is available for Linux and Mac OSX as well, I would prefer a Windows server.</span></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.funit.org/?feed=rss2&amp;p=185</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>FUnit equality assertion with Assert.areEqual()</title>
		<link>http://blog.funit.org/?p=93</link>
		<comments>http://blog.funit.org/?p=93#comments</comments>
		<pubDate>Sat, 06 Sep 2008 18:42:26 +0000</pubDate>
		<dc:creator>Ryan Christiansen</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Updates]]></category>
		<category><![CDATA[assertequals]]></category>
		<category><![CDATA[assertion]]></category>
		<category><![CDATA[equality]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[unit-testing]]></category>

		<guid isPermaLink="false">http://blog.funit.org/?p=93</guid>
		<description><![CDATA[This post represents an exhaustive list of supported value equatable object types. Relevant implementation details and code samples are available for each. Primitive types: int, uint, Number, Boolean, and String Coerced types: Date, XML, XMLList, Namespace, and QName Complex types: Array, ByteArray, and IList Primitive types: Numerics Assert.areEqual&#40; 123.456, 123.456 &#41;; Assert.areNotEqual&#40; 123, 123.456 &#41;; [...]]]></description>
			<content:encoded><![CDATA[<p>This post represents an exhaustive list of supported value equatable object types. Relevant implementation details and code samples are available for each.</p>
<ul>
<li><strong>Primitive types:</strong> <span style="color: #333399;"><strong></strong></span><span style="color: #333399;"><strong>int</strong></span>, <span style="color: #333399;"><strong>uint</strong></span>, <span style="color: #333399;"><strong>Number</strong></span>, <span style="color: #333399;"><strong>Boolean</strong></span>, and <span style="color: #333399;"><strong>String</strong></span></li>
<li><strong>Coerced types:</strong> <span style="color: #333399;"><strong>Date</strong></span>, <span style="color: #333399;"><strong>XML</strong></span>, <span style="color: #333399;"><strong>XMLList</strong></span>, <span style="color: #333399;"><strong>Namespace</strong></span>, and <span style="color: #333399;"><strong>QName</strong></span></li>
<li><strong>Complex types:</strong> <span style="color: #333399;"><strong>Array</strong></span>, <span style="color: #333399;"><strong>ByteArray</strong></span>, and <span style="color: #333399;"><strong>IList</strong></span></li>
</ul>
<h4><span style="color: #333399;">Primitive types:</span></h4>
<div><span style="color: #333399;">Numerics</span></div>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;">Assert.areEqual<span style="color: #000000;">&#40;</span> <span style="color: #000000; font-weight:bold;">123.456</span>, <span style="color: #000000; font-weight:bold;">123.456</span> <span style="color: #000000;">&#41;</span>;
Assert.areNotEqual<span style="color: #000000;">&#40;</span> <span style="color: #000000; font-weight:bold;">123</span>, <span style="color: #000000; font-weight:bold;">123.456</span> <span style="color: #000000;">&#41;</span>;
&nbsp;
<span style="color: #009900;">// Note: The following will pass in FUnit but fail in FlexUnit.</span>
<span style="color: #009900;">//       The condition (NaN == NaN) will actually fail in</span>
<span style="color: #009900;">//       ActionScript so special handling is required.</span>
Assert.areEqual<span style="color: #000000;">&#40;</span> <span style="color: #004993;">NaN</span>, <span style="color: #004993;">NaN</span> <span style="color: #000000;">&#41;</span>;</pre></div></div>

<div><span style="color: #333399;">Boolean</span></div>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;">Assert.areEqual<span style="color: #000000;">&#40;</span> <span style="color: #0033ff; font-weight: bold;">true</span>, <span style="color: #0033ff; font-weight: bold;">true</span> <span style="color: #000000;">&#41;</span>;
Assert.areNotEqual<span style="color: #000000;">&#40;</span> <span style="color: #0033ff; font-weight: bold;">true</span>, <span style="color: #0033ff; font-weight: bold;">false</span> <span style="color: #000000;">&#41;</span>;
&nbsp;
<span style="color: #009900;">// Although 'isTrue' or 'isFalse' is more appropriate here.</span>
Assert.isTrue<span style="color: #000000;">&#40;</span> <span style="color: #0033ff; font-weight: bold;">true</span> <span style="color: #000000;">&#41;</span>;</pre></div></div>

<div><span style="color: #333399;">String</span></div>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;">Assert.areEqual<span style="color: #000000;">&#40;</span> <span style="color: #990000;">&quot;hello world!&quot;</span>, <span style="color: #990000;">&quot;hello world!&quot;</span> <span style="color: #000000;">&#41;</span>;
Assert.areNotEqual<span style="color: #000000;">&#40;</span> <span style="color: #990000;">&quot;hello world!&quot;</span>, <span style="color: #990000;">&quot;goodbye world!&quot;</span> <span style="color: #000000;">&#41;</span>;
&nbsp;
<span style="color: #009900;">// The StringAssert class is better suited for more</span>
<span style="color: #009900;">// advanced string assertions.</span>
StringAssert.areEqualIgnoringCase<span style="color: #000000;">&#40;</span> <span style="color: #990000;">&quot;hello!&quot;</span>, <span style="color: #990000;">&quot;HELLO!&quot;</span> <span style="color: #000000;">&#41;</span>;
StringAssert.<span style="color: #004993;">isEmpty</span><span style="color: #000000;">&#40;</span> <span style="color: #990000;">&quot;&quot;</span> <span style="color: #000000;">&#41;</span>;
StringAssert.<span style="color: #004993;">contains</span><span style="color: #000000;">&#40;</span> <span style="color: #990000;">&quot;world&quot;</span>, <span style="color: #990000;">&quot;hello world!&quot;</span> <span style="color: #000000;">&#41;</span>;
StringAssert.startsWith<span style="color: #000000;">&#40;</span> <span style="color: #990000;">&quot;hello&quot;</span>, <span style="color: #990000;">&quot;hello world!&quot;</span> <span style="color: #000000;">&#41;</span>;
StringAssert.endsWith<span style="color: #000000;">&#40;</span> <span style="color: #990000;">&quot;!&quot;</span>, <span style="color: #990000;">&quot;hello world!&quot;</span> <span style="color: #000000;">&#41;</span>;
<span style="color: #009900;">// and so on ...</span></pre></div></div>

<h4><span style="color: #333399;">Coerced types:</span></h4>
<p><span style="color: #333399;"><strong>Important Note:</strong> In order to maintain simplicity in expected behavior, value coercion is limited to global top-level classes only. A &#8216;quick-reference&#8217; should not be necessary while writing equality tests. The only top-level classes <em>not</em> currently handled are <strong>Error</strong> and <strong>RegExp</strong>. This is largely due to the fact that they are <a href="http://en.wikipedia.org/wiki/Immutable_object">immutable objects</a> (cannot be changed after they are created). Pending further discussions and/or feedback, value coercion for these types will likely be added as well.</span></p>
<div><span style="color: #333399;">Date</span></div>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;">Assert.areEqual<span style="color: #000000;">&#40;</span> <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Date</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">123456</span><span style="color: #000000;">&#41;</span>, <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Date</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">123456</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#41;</span>;
Assert.areNotEqual<span style="color: #000000;">&#40;</span> <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Date</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">123456</span><span style="color: #000000;">&#41;</span>, <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Date</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">654321</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#41;</span>;
&nbsp;
<span style="color: #009900;">// Note: Unlike the .NET environment ActionScript does not</span>
<span style="color: #009900;">//       treat dates as a value type. Therefore, FUnit will</span>
<span style="color: #009900;">//       coerce the Date class to evaluate equality.</span>
<span style="color: #009900;">//       For reference equality use 'Assert.areSame()'.</span>
Assert.areNotSame<span style="color: #000000;">&#40;</span> <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Date</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">123456</span><span style="color: #000000;">&#41;</span>, <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Date</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">123456</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#41;</span>;</pre></div></div>

<div><span style="color: #333399;">XML / XMLList</span></div>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #6699cc; font-weight: bold;">var</span> xml1<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">XML</span> = <span style="color: #000000; font-weight: bold;">&lt;</span>value<span style="color: #000000; font-weight: bold;">&gt;</span>Hello World<span style="color: #000000; font-weight: bold;">&lt;/</span>value<span style="color: #000000; font-weight: bold;">&gt;</span>;
<span style="color: #6699cc; font-weight: bold;">var</span> xml2<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">XML</span> = <span style="color: #000000; font-weight: bold;">&lt;</span>value<span style="color: #000000; font-weight: bold;">&gt;</span>Hello World<span style="color: #000000; font-weight: bold;">&lt;/</span>value<span style="color: #000000; font-weight: bold;">&gt;</span>;
Assert.areEqual<span style="color: #000000;">&#40;</span> xml1, xml2 <span style="color: #000000;">&#41;</span>;
&nbsp;
<span style="color: #009900;">// Similar to Date class value coercion, FUnit can distinguish</span>
<span style="color: #009900;">// value equality from reference equality.</span>
Assert.areNotSame<span style="color: #000000;">&#40;</span> xml1, xml2 <span style="color: #000000;">&#41;</span>;</pre></div></div>

<div><span style="color: #333399;">Namespace / QName</span></div>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #6699cc; font-weight: bold;">var</span> ns1<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Namespace</span> =
     <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Namespace</span><span style="color: #000000;">&#40;</span> <span style="color: #990000;">&quot;funit&quot;</span>, <span style="color: #990000;">&quot;http://www.funit.org/2009/&quot;</span> <span style="color: #000000;">&#41;</span>;
<span style="color: #6699cc; font-weight: bold;">var</span> ns2<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Namespace</span> =
     <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Namespace</span><span style="color: #000000;">&#40;</span> <span style="color: #990000;">&quot;funit&quot;</span>, <span style="color: #990000;">&quot;http://www.funit.org/2009/&quot;</span> <span style="color: #000000;">&#41;</span>;
&nbsp;
Assert.areEqual<span style="color: #000000;">&#40;</span> ns1, ns2 <span style="color: #000000;">&#41;</span>;
Assert.areNotSame<span style="color: #000000;">&#40;</span> ns1, ns2 <span style="color: #000000;">&#41;</span>;
&nbsp;
<span style="color: #6699cc; font-weight: bold;">var</span> qname1<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">QName</span> =
     <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">QName</span> <span style="color: #000000;">&#40;</span> <span style="color: #990000;">&quot;http://www.funit.org/2009/&quot;</span>, <span style="color: #990000;">&quot;funit&quot;</span> <span style="color: #000000;">&#41;</span>;
<span style="color: #6699cc; font-weight: bold;">var</span> qname2<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">QName</span> =
     <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">QName</span> <span style="color: #000000;">&#40;</span> <span style="color: #990000;">&quot;http://www.funit.org/2009/&quot;</span>, <span style="color: #990000;">&quot;funit&quot;</span> <span style="color: #000000;">&#41;</span>;
&nbsp;
Assert.areEqual<span style="color: #000000;">&#40;</span> qname1, qname2 <span style="color: #000000;">&#41;</span>;
Assert.areNotSame<span style="color: #000000;">&#40;</span> qname1, qname2 <span style="color: #000000;">&#41;</span>;</pre></div></div>

<h4><span style="color: #333399;">Complex types:</span></h4>
<div><span style="color: #333399;">Array</span></div>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;">Assert.areEqual<span style="color: #000000;">&#40;</span> <span style="color: #000000;">&#91;</span><span style="color: #990000;">&quot;x&quot;</span>, <span style="color: #990000;">&quot;y&quot;</span>, <span style="color: #990000;">&quot;z&quot;</span><span style="color: #000000;">&#93;</span>, <span style="color: #000000;">&#91;</span><span style="color: #990000;">&quot;x&quot;</span>, <span style="color: #990000;">&quot;y&quot;</span>, <span style="color: #990000;">&quot;z&quot;</span><span style="color: #000000;">&#93;</span> <span style="color: #000000;">&#41;</span>;
Assert.areNotEqual<span style="color: #000000;">&#40;</span> <span style="color: #000000;">&#91;</span><span style="color: #990000;">&quot;x&quot;</span>, <span style="color: #990000;">&quot;y&quot;</span>, <span style="color: #990000;">&quot;z&quot;</span><span style="color: #000000;">&#93;</span>, <span style="color: #000000;">&#91;</span><span style="color: #990000;">&quot;x&quot;</span>, <span style="color: #990000;">&quot;y&quot;</span>, <span style="color: #990000;">&quot;a&quot;</span><span style="color: #000000;">&#93;</span> <span style="color: #000000;">&#41;</span>;
&nbsp;
<span style="color: #009900;">// Associative Arrays are also handled.</span>
<span style="color: #6699cc; font-weight: bold;">var</span> array1<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Array</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Array</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
array1<span style="color: #000000;">&#91;</span><span style="color: #990000;">&quot;firstName&quot;</span><span style="color: #000000;">&#93;</span> = <span style="color: #990000;">&quot;John&quot;</span>;
array1<span style="color: #000000;">&#91;</span><span style="color: #990000;">&quot;middleName&quot;</span><span style="color: #000000;">&#93;</span> = <span style="color: #990000;">&quot;Adam&quot;</span>;
array1<span style="color: #000000;">&#91;</span><span style="color: #990000;">&quot;lastName&quot;</span><span style="color: #000000;">&#93;</span> = <span style="color: #990000;">&quot;Doe&quot;</span>;
&nbsp;
<span style="color: #6699cc; font-weight: bold;">var</span> array2<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Array</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Array</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
array2<span style="color: #000000;">&#91;</span><span style="color: #990000;">&quot;firstName&quot;</span><span style="color: #000000;">&#93;</span> = <span style="color: #990000;">&quot;John&quot;</span>;
array2<span style="color: #000000;">&#91;</span><span style="color: #990000;">&quot;middleName&quot;</span><span style="color: #000000;">&#93;</span> = <span style="color: #990000;">&quot;Adam&quot;</span>;
array2<span style="color: #000000;">&#91;</span><span style="color: #990000;">&quot;lastName&quot;</span><span style="color: #000000;">&#93;</span> = <span style="color: #990000;">&quot;Doe&quot;</span>;
&nbsp;
Assert.areEqual<span style="color: #000000;">&#40;</span> array1, array2 <span style="color: #000000;">&#41;</span>;
&nbsp;
<span style="color: #009900;">// Complex recursive arrays are also handled by internally</span>
<span style="color: #009900;">// checking for re-entrant behaviors and preventing stack</span>
<span style="color: #009900;">// overflow.</span>
<span style="color: #6699cc; font-weight: bold;">var</span> recursive1<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Array</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Array</span><span style="color: #000000;">&#40;</span> <span style="color: #0033ff; font-weight: bold;">null</span>, <span style="color: #000000;">&#91;</span><span style="color: #990000;">&quot;x&quot;</span>, <span style="color: #990000;">&quot;y&quot;</span>, <span style="color: #990000;">&quot;z&quot;</span><span style="color: #000000;">&#93;</span>, <span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span> <span style="color: #000000;">&#41;</span>;
recursive1<span style="color: #000000;">&#91;</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#93;</span> = recursive1;
&nbsp;
<span style="color: #6699cc; font-weight: bold;">var</span> recursive2<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Array</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Array</span><span style="color: #000000;">&#40;</span> <span style="color: #0033ff; font-weight: bold;">null</span>, <span style="color: #000000;">&#91;</span><span style="color: #990000;">&quot;x&quot;</span>, <span style="color: #990000;">&quot;y&quot;</span>, <span style="color: #990000;">&quot;z&quot;</span><span style="color: #000000;">&#93;</span>, <span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span> <span style="color: #000000;">&#41;</span>;
recursive2<span style="color: #000000;">&#91;</span><span style="color: #000000; font-weight:bold;">0</span><span style="color: #000000;">&#93;</span> = recursive2;
&nbsp;
<span style="color: #009900;">// Note: No stack overflow will occur here, but more variations</span>
<span style="color: #009900;">//       and complex samples are needed to ensure all potential</span>
<span style="color: #009900;">//       loopholes are handled.</span>
Assert.areEqual<span style="color: #000000;">&#40;</span> recursive1, recursive2 <span style="color: #000000;">&#41;</span>;</pre></div></div>

<div><span style="color: #333399;">ByteArray</span></div>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #6699cc; font-weight: bold;">var</span> array1<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">ByteArray</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">ByteArray</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
array1.<span style="color: #004993;">writeDouble</span><span style="color: #000000;">&#40;</span> <span style="color: #004993;">Math</span>.<span style="color: #004993;">PI</span> <span style="color: #000000;">&#41;</span>;
array1.<span style="color: #004993;">writeUTF</span><span style="color: #000000;">&#40;</span> <span style="color: #990000;">&quot;Hello World&quot;</span> <span style="color: #000000;">&#41;</span>;
array1.<span style="color: #004993;">writeObject</span><span style="color: #000000;">&#40;</span> <span style="color: #000000;">&#91;</span><span style="color: #990000;">&quot;x&quot;</span>, <span style="color: #990000;">&quot;y&quot;</span>, <span style="color: #990000;">&quot;z&quot;</span><span style="color: #000000;">&#93;</span> <span style="color: #000000;">&#41;</span>;
&nbsp;
<span style="color: #6699cc; font-weight: bold;">var</span> array2<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">ByteArray</span> = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">ByteArray</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
array2.<span style="color: #004993;">writeDouble</span><span style="color: #000000;">&#40;</span> <span style="color: #004993;">Math</span>.<span style="color: #004993;">PI</span> <span style="color: #000000;">&#41;</span>;
array2.<span style="color: #004993;">writeUTF</span><span style="color: #000000;">&#40;</span> <span style="color: #990000;">&quot;Hello World&quot;</span> <span style="color: #000000;">&#41;</span>;
array2.<span style="color: #004993;">writeObject</span><span style="color: #000000;">&#40;</span> <span style="color: #000000;">&#91;</span><span style="color: #990000;">&quot;x&quot;</span>, <span style="color: #990000;">&quot;y&quot;</span>, <span style="color: #990000;">&quot;z&quot;</span><span style="color: #000000;">&#93;</span> <span style="color: #000000;">&#41;</span>;
&nbsp;
Assert.areEqual<span style="color: #000000;">&#40;</span> array1, array2 <span style="color: #000000;">&#41;</span>;
Assert.areNotSame<span style="color: #000000;">&#40;</span> array1, array2 <span style="color: #000000;">&#41;</span>;</pre></div></div>

<div><span style="color: #333399;">IList</span></div>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #6699cc; font-weight: bold;">var</span> set1<span style="color: #000000; font-weight: bold;">:</span>ArrayCollection =
     <span style="color: #0033ff; font-weight: bold;">new</span> ArrayCollection<span style="color: #000000;">&#40;</span> <span style="color: #000000;">&#91;</span><span style="color: #990000;">&quot;x&quot;</span>, <span style="color: #990000;">&quot;y&quot;</span>, <span style="color: #990000;">&quot;z&quot;</span><span style="color: #000000;">&#93;</span> <span style="color: #000000;">&#41;</span>;
<span style="color: #6699cc; font-weight: bold;">var</span> set2<span style="color: #000000; font-weight: bold;">:</span>ArrayCollection =
     <span style="color: #0033ff; font-weight: bold;">new</span> ArrayCollection<span style="color: #000000;">&#40;</span> <span style="color: #000000;">&#91;</span><span style="color: #990000;">&quot;x&quot;</span>, <span style="color: #990000;">&quot;y&quot;</span>, <span style="color: #990000;">&quot;z&quot;</span><span style="color: #000000;">&#93;</span> <span style="color: #000000;">&#41;</span>;
&nbsp;
Assert.areEqual<span style="color: #000000;">&#40;</span> set1, set2 <span style="color: #000000;">&#41;</span>;
Assert.areNotSame<span style="color: #000000;">&#40;</span> set1, set2 <span style="color: #000000;">&#41;</span>;</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://blog.funit.org/?feed=rss2&amp;p=93</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>FUnit Framework Update 0.50.245</title>
		<link>http://blog.funit.org/?p=87</link>
		<comments>http://blog.funit.org/?p=87#comments</comments>
		<pubDate>Wed, 03 Sep 2008 05:18:39 +0000</pubDate>
		<dc:creator>Ryan Christiansen</dc:creator>
				<category><![CDATA[Updates]]></category>
		<category><![CDATA[assertequals]]></category>
		<category><![CDATA[assertion]]></category>
		<category><![CDATA[equality]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[funit]]></category>
		<category><![CDATA[unit-testing]]></category>

		<guid isPermaLink="false">http://blog.funit.org/?p=87</guid>
		<description><![CDATA[The next major revision to the framework core is now available for download. Although there are few changes to the core runtime engine, this release represents significant research surrounding semantics of the Assert &#8216;areEqual&#8217; method. More in depth coverage of these issues are found here and here. A detailed article outlining the effects of this [...]]]></description>
			<content:encoded><![CDATA[<p>The next major revision to the framework core is now available for download. Although there are few changes to the core runtime engine, this release represents significant research surrounding semantics of the Assert &#8216;areEqual&#8217; method. More in depth coverage of these issues are found <a href="http://blog.funit.org/?p=13">here</a> and <a href="http://blog.funit.org/?p=14">here</a>.</p>
<p>A detailed article outlining the effects of this change will be available within the next few days.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.funit.org/?feed=rss2&amp;p=87</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Round 2: xUnit ‘assertEquals’ &#8211; JUnit/FlexUnit vs. NUnit/FUnit</title>
		<link>http://blog.funit.org/?p=14</link>
		<comments>http://blog.funit.org/?p=14#comments</comments>
		<pubDate>Tue, 02 Sep 2008 06:03:30 +0000</pubDate>
		<dc:creator>Ryan Christiansen</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Updates]]></category>
		<category><![CDATA[assertequals]]></category>
		<category><![CDATA[assertion]]></category>
		<category><![CDATA[equality]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[flexunit]]></category>
		<category><![CDATA[junit]]></category>
		<category><![CDATA[nunit]]></category>
		<category><![CDATA[unit-testing]]></category>

		<guid isPermaLink="false">http://blog.funit.org/?p=14</guid>
		<description><![CDATA[Don&#8217;t let the title fool you&#8230; JUnit, NUnit, FlexUnit, and I have gone round and round for weeks since my last post. Every time I thought I had adequately addressed the issue, a new crop of discoveries would start the battle over again. Despite the rough beginnings, however, I couldn&#8217;t be happier with the outcome. [...]]]></description>
			<content:encoded><![CDATA[<p>Don&#8217;t let the title fool you&#8230; <a href="http://www.junit.org/">JUnit</a>, <a href="http://www.nunit.org/">NUnit</a>, <a href="http://opensource.adobe.com/wiki/display/flexunit/Flexunit">FlexUnit</a>, and I have gone round and round for weeks since my last post. Every time I <em>thought</em> I had adequately addressed the issue, a new crop of discoveries would start the battle over again. Despite the rough beginnings, however, I couldn&#8217;t be happier with the outcome. Furthermore, the functional distinctions between FUnit and FlexUnit have gone beyond how tests are created and deeper into how they are written. Here is what I&#8217;ve discovered.</p>
<blockquote><h4><span style="color: #333399;">Discovery 1: All xUnit Frameworks are <strong><span style="text-decoration: underline;"><em>not</em></span></strong> created equal.</span></h4>
</blockquote>
<p>You may have noticed the addendum in my <a href="http://blog.funit.org/?p=13">last post</a> concerning JUnit vs. NUnit array equality. This was my first clue that striking the right balance between authoring language and developer intent was more art than science. The <a href="http://en.wikipedia.org/wiki/XUnit">xUnit</a> pattern is a means of providing ubiquity across languages, while it is the responsibility of the framework instance to tailor to the needs of the language. With this in mind, controlled deviations among testing frameworks is not only common but preferable.</p>
<div><span style="color: #333399;"><strong>Note the JUnit source code for &#8216;assertEquals&#8217; here:</strong></span></div>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> assertEquals<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> message, <span style="color: #003399;">Object</span> expected, <span style="color: #003399;">Object</span> actual<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>expected <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">null</span> <span style="color: #339933;">&amp;&amp;</span> actual <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span>
		<span style="color: #000000; font-weight: bold;">return</span><span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>expected <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">null</span> <span style="color: #339933;">&amp;&amp;</span> expected.<span style="color: #006633;">equals</span><span style="color: #009900;">&#40;</span>actual<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
		<span style="color: #000000; font-weight: bold;">return</span><span style="color: #339933;">;</span>
	failNotEquals<span style="color: #009900;">&#40;</span>message, expected, actual<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>As you see in the above JUnit example, &#8216;assertEquals&#8217; relies on a call to the &#8216;expected&#8217; data types <em>Object.equals()</em> implementation. I confess, I was under the false impression that this method served as a member-wise equality comparer. On the contrary, the default behavior for <em>Object.equals()</em> is actually <span style="text-decoration: underline;"><em>reference</em></span> equality. I also discovered that this method is <span style="text-decoration: underline;"><em>rarely</em></span> overridden outside of primitive types such as String, Boolean, Double, Single, etc. This means that in terms of JUnit, &#8216;assertEquals&#8217; behaves more like &#8216;assertSame&#8217; in most cases.</p>
<p>NUnit takes a different approach to object equality. In addition to performing value comparison of primitive types, NUnit adds a few others&#8230; Array, ICollection (equatable to IList in AS3), Stream and Date. In such cases, NUnit &#8216;areEqual&#8217; ensures that the <span style="text-decoration: underline;"><em>value</em></span> of the comparing types are equal without relying solely on reference equality. <em>Object.equals()</em> is still used by NUnit but only after all other value comparisons have failed.</p>
<div><span style="color: #333399;"><strong>The following array equality assertion in NUnit will <span style="color: #339966;">pass</span>.</strong></span></div>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> array1 <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span> <span style="color: #0000ff;">&quot;one&quot;</span>, <span style="color: #0000ff;">&quot;two&quot;</span>, <span style="color: #0000ff;">&quot;three&quot;</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
<span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> array2 <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span> <span style="color: #0000ff;">&quot;one&quot;</span>, <span style="color: #0000ff;">&quot;two&quot;</span>, <span style="color: #0000ff;">&quot;three&quot;</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">Assert</span>.<span style="color: #006633;">assertEquals</span><span style="color: #009900;">&#40;</span>array1, array2<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>There is a similar method available in JUnit called <em>Assert.assertArrayEquals()</em>. I&#8217;d like to point out here that there are actually two Assert classes in JUnit, &#8216;junit.frameworks::Assert&#8217; and &#8216;org.junit::Assert&#8217;. This is a good indicator that JUnit has been rethinking its testing approach as well. Legacy support is a primary factor of &#8220;why things are they way they are&#8221;. Once an established framework like JUnit has put its stakes in the ground, it&#8217;s hard to move them.</p>
<blockquote><h4><span style="color: #333399;">Discovery 2: All languages are <strong><span style="text-decoration: underline;"><em>not</em></span></strong> created equal&#8230; duh.</span></h4>
</blockquote>
<p>The JUnit &#8216;assertEquals&#8217; code sample is a bit misleading. What you don&#8217;t see is that there are actually 19 other methods just like it. These method <a href="http://en.wikipedia.org/wiki/Method_overloading">overloads</a> serve as a form of type equality check. In order for two types to be compared by value, they must be of equivalent types. In fact, in some languages comparison of incompatible types won&#8217;t even compile.</p>
<div><span style="color: #333399;"><strong>Compilation of the following condition in C# will <span style="color: #ff0000;">fail</span>.</strong></span></div>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;">Boolean value <span style="color: #008000;">=</span> <span style="color: #000000;">&#40;</span><span style="color: #FF0000;">123456</span> <span style="color: #008000;">==</span> <span style="color: #666666;">&quot;123456&quot;</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">?</span> <span style="color: #0600FF;">true</span> <span style="color: #008000;">:</span> false<span style="color: #008000;">;</span>
&nbsp;
<span style="color: #008080; font-style: italic;">// The following error will be thrown</span>
<span style="color: #0600FF;">Operator</span> <span style="color: #666666;">'=='</span> cannot be applied to operands
     of type <span style="color: #666666;">'int'</span> and <span style="color: #666666;">'string'</span></pre></div></div>

<p>Unfortunately, method overloading is not even supported in ActionScript 3. Equally unfortunate, FlexUnit makes no attempt to account for such type mismatches. Type equality is a key component of value equality. The inclusion of FlexUnit &#8216;assertStrictEquals&#8217; is a step in the right direction but still relies heavily on developers to do the leg work.</p>
<div><span style="color: #333399;"><strong>The following equality assertion in FlexUnit will <span style="color: #339966;">pass</span>.</strong></span></div>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #6699cc; font-weight: bold;">var</span> xml1<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">XML</span> = <span style="color: #000000; font-weight: bold;">&lt;</span>value<span style="color: #000000; font-weight: bold;">&gt;</span>Hello World<span style="color: #000000; font-weight: bold;">&lt;/</span>value<span style="color: #000000; font-weight: bold;">&gt;</span>;
<span style="color: #6699cc; font-weight: bold;">var</span> xml2<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">XML</span> = <span style="color: #000000; font-weight: bold;">&lt;</span>value<span style="color: #000000; font-weight: bold;">&gt;</span>Hello World<span style="color: #000000; font-weight: bold;">&lt;/</span>value<span style="color: #000000; font-weight: bold;">&gt;</span>;
Assert.assertEquals<span style="color: #000000;">&#40;</span>xml1, xml2<span style="color: #000000;">&#41;</span>;</pre></div></div>

<div><span style="color: #333399;"><strong>The following equality assertions in FlexUnit will <span style="color: #ff0000;">fail</span>.</strong></span></div>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #6699cc; font-weight: bold;">var</span> xml1<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">XML</span> = <span style="color: #000000; font-weight: bold;">&lt;</span>value<span style="color: #000000; font-weight: bold;">&gt;</span>Hello World<span style="color: #000000; font-weight: bold;">&lt;/</span>value<span style="color: #000000; font-weight: bold;">&gt;</span>;
<span style="color: #6699cc; font-weight: bold;">var</span> xml2<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">XML</span> = <span style="color: #000000; font-weight: bold;">&lt;</span>value<span style="color: #000000; font-weight: bold;">&gt;</span>Hello World<span style="color: #000000; font-weight: bold;">&lt;/</span>value<span style="color: #000000; font-weight: bold;">&gt;</span>;
Assert.assertStrictEquals<span style="color: #000000;">&#40;</span>xml1, xml2<span style="color: #000000;">&#41;</span>;</pre></div></div>

<p>In this example, standard equality (==) on XML is a value comparison while strict equality (===) is a reference comparison. It becomes a requirement, therefore, that a developer be intimately familiar with the nuances of each equality type and its variances across data types. I would argue that maintaining separation between Assert.areEqual() and Assert.areSame() is much clearer to the developer (but much harder on me).</p>
<blockquote><h4><span style="color: #333399;">Discovery 3: FlexUnit is to JUnit as FUnit is to NUnit.</span></h4>
</blockquote>
<p>The more I study the mechanics of the JUnit and NUnit testing frameworks, the clearer the distinction is between the two. Given ActionScript&#8217;s strong Java influence, it makes sense that Adobe would choose to pattern FlexUnit after JUnit. I will also say that the developers of FlexUnit did an oustanding job mirroring the testing patterns of JUnit. If you can unit-test in Java with JUnit then you can unit-test in Flash with FlexUnit and vice versa. That&#8217;s a very powerful thing.</p>
<p>There&#8217;s just one problem&#8230; I don&#8217;t like JUnit&#8230; at all.</p>
<p>Due to patterns established by JUnit, I believe it has made FlexUnit unnecessarily complex for both framing and writing tests. In fact, it was my initial frustrations with FlexUnit (and the JUnit pattern) that led me to establish the FUnit framework. More specifically, I didn&#8217;t have the same frustrating experience when using NUnit. Here&#8217;s just a couple of ways that NUnit spoiled me.</p>
<ul>
<li>No need to extend the TestCase base class</li>
<li>Tests are easily flagged with the [Test] metadata tag</li>
<li>No “test” prefix is required for TestCase methods to be reflected</li>
<li>Expected errors are marked with an [ExpectedError] tag (no wrapper code)</li>
<li>Supports SetUp, TearDown, FixtureSetUp, and FixtureTearDown</li>
</ul>
<p>It should come as no surprise that I&#8217;ve sided with NUnit on this one. A simple <a href="http://blog.funit.org/?p=4">side-by-side comparison</a> of FlexUnit vs. FUnit markup makes it pretty obvious why I like it.</p>
<p>There&#8217;s far more to this topic than I was able to post here but I hope I&#8217;ve provided sufficient background to describe the issues at hand. For those of you pulling regular svn <a href="http://blog.funit.org/?page_id=5">updates</a>, the core changes have been implemented and are available for use. Since I&#8217;d rather not unnecessarily muddle the problem and solution, a detailed explanation of these changes merits an article of it&#8217;s own. Look for this article shortly along with an official update release.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.funit.org/?feed=rss2&amp;p=14</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Critical Issue: FlexUnit &#8216;assertEquals&#8217; Breaks xUnit Convention</title>
		<link>http://blog.funit.org/?p=13</link>
		<comments>http://blog.funit.org/?p=13#comments</comments>
		<pubDate>Mon, 07 Jul 2008 07:03:43 +0000</pubDate>
		<dc:creator>Ryan Christiansen</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Updates]]></category>
		<category><![CDATA[assertequals]]></category>
		<category><![CDATA[assertion]]></category>
		<category><![CDATA[equality]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[flexunit]]></category>
		<category><![CDATA[junit]]></category>
		<category><![CDATA[nunit]]></category>
		<category><![CDATA[unit-testing]]></category>

		<guid isPermaLink="false">http://blog.funit.org/?p=13</guid>
		<description><![CDATA[It is not my intention to discredit FlexUnit&#8217;s decision to diverge it&#8217;s implementation from other testing frameworks, but rather to ensure that FUnit is firmly planted in what the testing community considers the de facto standard. I will cite JUnit and NUnit as references for xUnit best practice. These frameworks are long established and widely [...]]]></description>
			<content:encoded><![CDATA[<p>It is not my intention to discredit FlexUnit&#8217;s decision to diverge it&#8217;s implementation from other testing frameworks, but rather to ensure that FUnit is firmly planted in what the testing community considers the de facto standard.</p>
<p>I will cite <a href="http://www.junit.org">JUnit</a> and <a href="http://www.nunit.org">NUnit</a> as references for xUnit best practice. These frameworks are long established and widely adopted tools for unit-testing in the Java and .NET languages. The discrepancy between JUnit/NUnit and FlexUnit can be summarized as follows:</p>
<blockquote><p><span style="color: #333399;">JUnit &#8216;<em>assertEquals</em>&#8216; / NUnit &#8216;<em>areEqual</em>&#8216; assert <strong><span style="text-decoration: underline;"><em>value</em></span></strong> equality.<br />
FlexUnit &#8216;<em>assertEquals</em>&#8216; asserts <strong><span style="text-decoration: underline;"><em>reference</em></span></strong> equality.</span></p></blockquote>
<p>When evaluating equality of value types such as Boolean, String, Number, etc. the behavior will be similar in <span style="text-decoration: underline;"><em>most</em></span> cases (we&#8217;ll outline these differences later). Test outcome for Object and Array assertions, however, may be drastically different between FlexUnit and other xUnit frameworks.</p>
<p><span style="color: #BB0000;"><strong>Important Correction:</strong> Since posting this article I&#8217;ve discovered that the JUnit method overload <strong>Assert.assertEquals</strong>(object[], object[]) has been deprecated and replaced by <strong>Assert.assertArrayEquals</strong>(object[], object[]). Variance between JUnit and NUnit may indicate that minor inconsistencies exist between testing frameworks as a whole and is not limited to FlexUnit alone. Further discussions on this topic and how it pertains to FUnit will continue <a href="http://blog.funit.org/?p=14">here</a>.</span></p>
<div><span style="color: #333399;"><strong>The following array equality assertion in JUnit will <span style="color: #339966;">pass</span>.</strong></span></div>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> array1 <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span> <span style="color: #0000ff;">&quot;one&quot;</span>, <span style="color: #0000ff;">&quot;two&quot;</span>, <span style="color: #0000ff;">&quot;three&quot;</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
<span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> array2 <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span> <span style="color: #0000ff;">&quot;one&quot;</span>, <span style="color: #0000ff;">&quot;two&quot;</span>, <span style="color: #0000ff;">&quot;three&quot;</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">Assert</span>.<span style="color: #006633;">assertArrayEquals</span><span style="color: #009900;">&#40;</span>array1, array2<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<div><span style="color: #333399;"><strong>The following array equality assertion in NUnit will <span style="color: #339966;">pass</span>.</strong></span></div>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #FF0000;">String</span><span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span> array1 <span style="color: #008000;">=</span> <span style="color: #000000;">&#123;</span> <span style="color: #666666;">&quot;one&quot;</span>, <span style="color: #666666;">&quot;two&quot;</span>, <span style="color: #666666;">&quot;three&quot;</span> <span style="color: #000000;">&#125;</span><span style="color: #008000;">;</span>
<span style="color: #FF0000;">String</span><span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span> array2 <span style="color: #008000;">=</span> <span style="color: #000000;">&#123;</span> <span style="color: #666666;">&quot;one&quot;</span>, <span style="color: #666666;">&quot;two&quot;</span>, <span style="color: #666666;">&quot;three&quot;</span> <span style="color: #000000;">&#125;</span><span style="color: #008000;">;</span>
Assert.<span style="color: #0000FF;">assertEquals</span><span style="color: #000000;">&#40;</span>array1, array2<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span></pre></div></div>

<div><span style="color: #333399;"><strong>The following array equality assertion in FlexUnit will <span style="color: #ff0000;">fail</span>.</strong></span></div>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #6699cc; font-weight: bold;">var</span> array1<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Array</span> = <span style="color: #000000;">&#91;</span> <span style="color: #990000;">&quot;one&quot;</span>, <span style="color: #990000;">&quot;two&quot;</span>, <span style="color: #990000;">&quot;three&quot;</span> <span style="color: #000000;">&#93;</span>;
<span style="color: #6699cc; font-weight: bold;">var</span> array2<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Array</span> = <span style="color: #000000;">&#91;</span> <span style="color: #990000;">&quot;one&quot;</span>, <span style="color: #990000;">&quot;two&quot;</span>, <span style="color: #990000;">&quot;three&quot;</span> <span style="color: #000000;">&#93;</span>;
Assert.assertEquals<span style="color: #000000;">&#40;</span>array1, array2<span style="color: #000000;">&#41;</span>;</pre></div></div>

<p>The intent of &#8216;assertEquals&#8217; according to xUnit convention is to ensure that the <span style="text-decoration: underline;"><em>value</em></span> of two objects are identical, <em>not</em> that they <span style="text-decoration: underline;"><em>reference</em></span> the same object. A second assertion type &#8216;assertSame&#8217; exists in JUnit (&#8216;areSame&#8217; for NUnit) to ensure that two objects share the same memory reference.</p>
<p>There are 3 possible reasons that may have lead FlexUnit developers to change the assertEquals implementation.</p>
<ul>
<li>Inconsistencies between the ActionScript Object class and other languages.</li>
<li>Existence of two Flash equality types; equals (==) and strict equals (===).</li>
<li>Flash developer expectations and implied meaning of &#8216;assertEquals&#8217;.</li>
</ul>
<h4>Relevant Language Differences Between ActionScript and Java and .NET</h4>
<p>The primary difference between the ActionScript Object definition and it&#8217;s Java/.NET counterparts is the absence of an Object.equals() method. All Java/.NET objects inherit from or override this method. Unfortunately, there is no ActionScript equivalent for member-wise equality comparison.</p>
<p>Object.equals() plays a crucial role in the &#8216;assertEquals&#8217; implementation.</p>
<div><span style="color: #333399;"><strong>Note the JUnit source code for &#8216;assertEquals&#8217; here:</strong></span></div>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> assertEquals<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> message, <span style="color: #003399;">Object</span> expected, <span style="color: #003399;">Object</span> actual<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>expected <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">null</span> <span style="color: #339933;">&amp;&amp;</span> actual <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span>
		<span style="color: #000000; font-weight: bold;">return</span><span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>expected <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">null</span> <span style="color: #339933;">&amp;&amp;</span> expected.<span style="color: #006633;">equals</span><span style="color: #009900;">&#40;</span>actual<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
		<span style="color: #000000; font-weight: bold;">return</span><span style="color: #339933;">;</span>
	failNotEquals<span style="color: #009900;">&#40;</span>message, expected, actual<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<h4>Standard Equality Vs. Strict Equality</h4>
<p>It is important to note here that &#8216;standard equality&#8217; (==) is a looser form of equality that does not exist in Java/.NET. These languages use what Flash considers &#8216;strict equality&#8217; (===). Behavioral differences between these types become apparent when evaluating equality of value types (Boolean, String, Number, etc.).</p>
<div><span style="color: #333399;"><strong>The following equality assertion in JUnit (or NUnit) will <span style="color: #ff0000;">fail</span>.</strong></span></div>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000066; font-weight: bold;">int</span> value1 <span style="color: #339933;">=</span> <span style="color: #cc66cc;">5</span><span style="color: #339933;">;</span>
<span style="color: #003399;">String</span> value2 <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;5&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">Assert</span>.<span style="color: #006633;">assertEquals</span><span style="color: #009900;">&#40;</span>value1, value2<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<div><span style="color: #333399;"><strong>The following equality assertion in FlexUnit will <span style="color: #339966;">pass</span>.</strong></span></div>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #6699cc; font-weight: bold;">var</span> value1<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">int</span> = <span style="color: #000000; font-weight:bold;">5</span>;
<span style="color: #6699cc; font-weight: bold;">var</span> value2<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">String</span>= <span style="color: #990000;">&quot;5&quot;</span>;
Assert.assertEquals<span style="color: #000000;">&#40;</span>value1, value2<span style="color: #000000;">&#41;</span>;</pre></div></div>

<p>According to the Flash Language Reference:</p>
<blockquote><p>The strict equality (===) operator differs from the equality (==) operator in only two ways:</p>
<ul>
<li>The strict equality operator performs automatic data conversion only for the number types (Number, int, and uint), whereas the equality operator performs automatic data conversion for all primitive data types.</li>
<li>When comparing null and undefined, the strict equality operator returns false.</li>
</ul>
</blockquote>
<p>In other words, &#8216;standard equality&#8217; does not enforce <em>type equality</em> of value types. This is inconsistent with other strong-typed languages.</p>
<h4>User Expectation</h4>
<p>Admittedly, my initial impressions of &#8216;assertEquals&#8217; is that i would perform reference comparison. If you say &#8220;Assert that value1 and value2 are equal.&#8221;, it would be easy to visualize &#8220;value1 == value2&#8243;. Since this is <em>not</em> what will be executed, this could be viewed as misleading.</p>
<h4>Proposed Solution</h4>
<p>The FUnit framework was designed to be intuitive. It was also designed to be ubiquitous with other frameworks. I don&#8217;t want developers of JUnit, NUnit, or FUnit tests to have to change their logic just because they switch languages. The less you have to think about the tools, the more focused you can be on using them.</p>
<p>I would opt for a stronger more consistent xUnit form of equality assertion. This however might require minor changes when migrating tests from FlexUnit implementations. I would also create a secondary LegacyAssert class that would perform identically to it&#8217;s FlexUnit counterpart. This would allow the developer to choose between xUnit convention or a more familiar FlexUnit behavior (or both in combination). This will ultimately empower the developer to be more explicit in their unit-testing.</p>
<div><span style="color: #333399;"><strong>FUnit Assert API</strong></span></div>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #339966; font-weight: bold;">function</span> areEqual<span style="color: #000000;">&#40;</span> expected<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Object</span>, actual<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Object</span> <span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">:</span> <span style="color: #0033ff; font-weight: bold;">void</span>
<span style="color: #339966; font-weight: bold;">function</span> areSame<span style="color: #000000;">&#40;</span> expected<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Object</span>, actual<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Object</span> <span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">:</span> <span style="color: #0033ff; font-weight: bold;">void</span></pre></div></div>

<div><span style="color: #333399;"><strong>FUnit LegacyAssert API</strong></span></div>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #339966; font-weight: bold;">function</span> areEqual<span style="color: #000000;">&#40;</span> expected<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Object</span>, actual<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Object</span> <span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">:</span> <span style="color: #0033ff; font-weight: bold;">void</span>
<span style="color: #339966; font-weight: bold;">function</span> areStrictEqual<span style="color: #000000;">&#40;</span> expected<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Object</span>, actual<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Object</span> <span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">:</span> <span style="color: #0033ff; font-weight: bold;">void</span></pre></div></div>

<div>
	<div class='democracy'>
		<strong class="poll-question">Which 'assertEquals' implementation works best for you?</strong>
		<div class='dem-results'>
		<form action='http://blog.funit.org/wp-content/plugins/democracy/democracy.php' onsubmit='return dem_Vote(this)'>
		<ul>
			<li>
					<input type='radio' id='dem-choice-6' value='6' name='dem_poll_2' />
					<label for='dem-choice-6'>xUnit 'by value' Standard w/ Legacy Support</label>
			</li>
			<li>
					<input type='radio' id='dem-choice-7' value='7' name='dem_poll_2' />
					<label for='dem-choice-7'>FlexUnit 'by reference' Standard</label>
			</li>
			<li>
					<input type='radio' id='dem-choice-8' value='8' name='dem_poll_2' />
					<label for='dem-choice-8'>uh... What was the question again?</label>
			</li>
			<li>
					<input type='radio' id='dem-choice-10' value='10' name='dem_poll_2' />
					<label for='dem-choice-10'>Other (contact me)</label>
			</li>
		</ul>
			<input type='hidden' name='dem_poll_id' value='2' />
			<input type='hidden' name='dem_action' value='vote' />
			<input type='submit' class='dem-vote-button' value='Vote' />
			<a href="http://blog.funit.org/?feed=rss2&amp;dem_action=view&amp;dem_poll_id=2" onclick='return dem_getVotes("http://blog.funit.org/wp-content/plugins/democracy/democracy.php?dem_action=view&amp;dem_poll_id=2", this)' rel='nofollow' class='dem-vote-link'>View Results</a>
		</form>
		</div>
	</div></div>
]]></content:encoded>
			<wfw:commentRss>http://blog.funit.org/?feed=rss2&amp;p=13</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>FUnit Community Issue Tracking Now Available</title>
		<link>http://blog.funit.org/?p=12</link>
		<comments>http://blog.funit.org/?p=12#comments</comments>
		<pubDate>Sun, 01 Jun 2008 06:43:40 +0000</pubDate>
		<dc:creator>Ryan Christiansen</dc:creator>
				<category><![CDATA[Updates]]></category>
		<category><![CDATA[Community]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[funit]]></category>
		<category><![CDATA[issue-tracking]]></category>
		<category><![CDATA[lighthouse]]></category>
		<category><![CDATA[unit-testing]]></category>

		<guid isPermaLink="false">http://blog.funit.org/?p=12</guid>
		<description><![CDATA[I realize there are countless web-based issue tracking systems available. These systems vary widely from open source to high dollar enterprise installations. Unfortunately, I had a number restricting factors that virtually eliminated all of them. Guru Not Included: My server-side experience is&#8230; less than ideal. Hosting Restrictions: I don&#8217;t have the resources to support X [...]]]></description>
			<content:encoded><![CDATA[<p>I realize there are countless web-based issue tracking systems available. These systems vary widely from open source to high dollar enterprise installations. Unfortunately, I had a number restricting factors that virtually eliminated all of them.</p>
<ul>
<li><strong>Guru Not Included:</strong> My server-side experience is&#8230; less than ideal.</li>
<li><strong>Hosting Restrictions:</strong> I don&#8217;t have the resources to support X or Y technology.</li>
<li><strong>Complex Setup:</strong> Near impossible in absence of said &#8220;server-side experience&#8221;</li>
<li><strong>Expensive:</strong> Open source projects aren&#8217;t always funded, including this one.</li>
<li><strong>Option Nightmare:</strong> It crams so many &#8220;features&#8221;, it&#8217;s practically unusable.</li>
<li><strong>Wrong Target User:</strong> I don&#8217;t need much, but give me what I need.</li>
<li><strong>Ugly Ugly Ugly:</strong> People DO judge a book by it&#8217;s cover&#8230;</li>
</ul>
<p>I finally found &#8220;just what I was looking for&#8221;. There is room to grow but <a title="Lighthouse, Beautifully simple issue tracking and bug reporting." href="http://www.lighthouseapp.com/" target="_blank">Lighthouse</a> sailed past my limitation gauntlet with flying colors.<a title="Lighthouse issue tracking and bug reporting" href="http://lighthouseapp.com/" target="_blank"><img class="alignleft" style="border: 0pt none; margin: 0px; margin-top: 10px; margin-right: 10px; float: left;" src="http://blog.funit.org/wp-content/images/Community_Issue_Tracking_Now_Available/lighthouse-logo.jpg" alt="Lighthouse, Beautifully simple issue tracking and bug reporting." width="238" height="70" /></a> I was able to create my account and begin roughing out community-based milestones and tickets almost immediately. The tools are simple and intuitive, and a good looking interface never hurt anybody. Better still, this hosted solution is free for open-source projects. Although I found this option available on other commercial products, I still preferred this one.</p>
<p>Lighthouse will help provide better visibility into FUnit development planning and changes as well as a sounding board for desired features and bug fixes. The new <a title="Community Issue Tracking Dashboard" href="http://funit.lighthouseapp.com/projects/11789-funit-testing-framework" target="_self">Issue Tracking Dashboard</a> is now active and I encourage community involvment. Please do not hesitate to create new tickets for any desirables or bugs you may encounter. You may also comment on existing tickets to raise their priority and I will do my best to expedite those areas.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.funit.org/?feed=rss2&amp;p=12</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>FlexCover &#8211; Finally Code Coverage for Flex</title>
		<link>http://blog.funit.org/?p=11</link>
		<comments>http://blog.funit.org/?p=11#comments</comments>
		<pubDate>Mon, 26 May 2008 03:59:41 +0000</pubDate>
		<dc:creator>Ryan Christiansen</dc:creator>
				<category><![CDATA[Updates]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[code-coverage]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[flexcover]]></category>
		<category><![CDATA[funit]]></category>

		<guid isPermaLink="false">http://blog.funit.org/?p=11</guid>
		<description><![CDATA[I discovered that within the past few days, Joseph Berkovitz and Alex Uhlmann have released Flexcover 0.50. I believe this project will be a tremendous asset for FUnit and I will be closely following it&#8217;s progress. There is one feature in particular I&#8217;m especially impressed with. FlexCover now supports Branch Coverage. This is the first [...]]]></description>
			<content:encoded><![CDATA[<p>I discovered that within the past few days, <a href="http://www.joeberkovitz.com/" target="_blank">Joseph Berkovitz</a> and Alex Uhlmann have released <a href="http://code.google.com/p/flexcover/">Flexcover 0.50</a>. I believe this project will be a tremendous asset for FUnit and I will be closely following it&#8217;s progress.</p>
<p>There is one feature in particular I&#8217;m especially impressed with. FlexCover now supports Branch Coverage. This is the first major step in not only providing test coverage, but test coverage <em>quality</em>. Just because a test executes your class method, doesn&#8217;t mean that all the code in that method is called. This is where Branch Coverage steps in. In a nutshell, FlexCover tracks every condition (if, else if) and whether it passes or fails. Obviously, if the condition fails, it&#8217;s code will never be executed&#8230;or tested.</p>
<p><a title="Coverage Viewer Detail" href="http://blog.funit.org/wp-content/images/FlexCover_CodeCoverage_Demo1/CoverageViewer.jpg" target="_self"><img style="border: 0; margin: 0px; margin-bottom: 10px" src="http://blog.funit.org/wp-content/images/FlexCover_CodeCoverage_Demo1/BranchCoverageSample.jpg" alt="FUnit Branch Coverage Sample" width="475" height="400" /></a></p>
<p>One major caveat to FlexCover, however, is that it requires a &#8220;modified&#8221; Flex compiler. This is how the coverage &#8220;hooks&#8221; are injected into your application code. In addition, this step is needed emit detailed metadata of your code, files, and application structure. I anticipate that given Alex&#8217;s ties with <a title="Adobe" href="http://www.adobe.com" target="_blank">Adobe</a> that there will be better compiler extensibility available with the introduction of <a title="Flex 4 Open Source Project" href="http://opensource.adobe.com/wiki/display/flexsdk/Flex+4" target="_blank">Flex 4</a> next year. Perhaps then this will no longer be necessary.</p>
<p>I have to say, the documentation for such an early project is excellent and very well outlined. I was able to get good coverage analysis for FUnit itself. I was able to create a small sub-set of FlexCover&#8217;s AIR based CoverageViewer for the web. Sadly, the source view that demonstrates the branch count won&#8217;t be available online (for now). The sample coverage data is viewable <a title="FlexCover anaysis of FUnit testing" href="http://www.funit.org/demo/TestCoverageDemo1/" target="_blank">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.funit.org/?feed=rss2&amp;p=11</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>FUnit Framework Roadmap</title>
		<link>http://blog.funit.org/?p=10</link>
		<comments>http://blog.funit.org/?p=10#comments</comments>
		<pubDate>Thu, 03 Apr 2008 03:12:58 +0000</pubDate>
		<dc:creator>Ryan Christiansen</dc:creator>
				<category><![CDATA[Updates]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[funit]]></category>
		<category><![CDATA[roadmap]]></category>
		<category><![CDATA[unit-testing]]></category>

		<guid isPermaLink="false">http://blog.funit.org/?p=10</guid>
		<description><![CDATA[Copyright © 2008 FUnit.org. All rights reserved.]]></description>
			<content:encoded><![CDATA[<p><img style="border: 0; margin: 0px;" src="http://blog.funit.org/wp-content/images/FUnitRoadmap.jpg" alt="FUnit Development Roadmap" width="475" height="633" /></p>
<p style="text-align: center;">Copyright © 2008 FUnit.org. All rights reserved.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.funit.org/?feed=rss2&amp;p=10</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
