<?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>Eamonn Faherty &#187; flashtdd</title>
	<atom:link href="http://blog.eamonnfaherty.co.uk/tag/flashtdd/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.eamonnfaherty.co.uk</link>
	<description>technology enthusiast and public speaker</description>
	<lastBuildDate>Tue, 21 Jun 2011 10:14:19 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.5</generator>
		<item>
		<title>Unit testing in actionscript3</title>
		<link>http://blog.eamonnfaherty.co.uk/2011/02/15/unit-testing-in-actionscript3/</link>
		<comments>http://blog.eamonnfaherty.co.uk/2011/02/15/unit-testing-in-actionscript3/#comments</comments>
		<pubDate>Tue, 15 Feb 2011 23:14:25 +0000</pubDate>
		<dc:creator>eamonn</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[flashtdd]]></category>
		<category><![CDATA[tdd]]></category>

		<guid isPermaLink="false">http://blog.eamonnfaherty.co.uk/?p=350</guid>
		<description><![CDATA[I was asked by a friend recently to point him in the direction of some advice on unit testing within actionscript 3. I thought it may be useful to others so here is the email with some addition descriptions: What is unit testing Unit tests are methods that run in order to verify the output of a method is what is expected when given a predefined input. This is useful as you can check if your code does what it should. There is a whole world of information on this on the internet. Check out test driven development. History ThereRead more


No related posts.

Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>I was asked by a friend recently to point him in the direction of some advice on unit testing within actionscript 3.  I thought it may be useful to others so here is the email with some addition descriptions:</p>
<p><strong>What is unit testing</strong><br />
Unit tests are methods that run in order to verify the output of a method is what is expected when given a predefined input.  This is useful as you can check if your code does what it should.  There is a whole world of information on this on the internet.  Check out test driven development.</p>
<p><strong>History</strong><br />
There used to be a few different unit testing frameworks &#8211; flexunit, fluint and asunit.  asunit was the fastest to run but has not been too popular.  I am not sure why.  Fluint was a flex-centric testing framework with stuff like ui impersonator (mocking).  Flexunit was the most used.</p>
<p><strong>Current</strong><br />
Flexunit was taken on (again) by Adobe and merged with fluint.  After adobe took it on again they named it version 4, probably to bring versioning inline with Flash Builder and flex.  with this change they improved the API to introduce metadata for methods so that they are run before, after and as test methods. It is now distributed with hamcrest (same as the java hamcrest library) and a number of runners and listeners.  It is the most used and it is the one i would recommend.</p>
<p><strong>How it works</strong><br />
You write the unit test in any of the supported styles (flexunit 1, flexunit 4 or fluent or maybe even in another style) and you mark them to run with the associated runner (using metadata).  You then run the tests using that test runner.  Whilst the test runs a listener is also run.  There are multiple test listeners, they are for different environments &#8211; to be run on a ci box, in the browser, in the IDE etc.</p>
<p><strong>Continuous Integration</strong><br />
You cannot currently run unit tests without a flash player.  You cannot currently run a flash player without a virtual frame buffer (think that is the term) or without a window manager running. With hudson (or jenkins now) you can install and run the vnc plugin, this has been the easiest way I have found so far.  This takes care of all that stuff for you.  It even deals with multiple vnc sessions at the same time if you have more than one hudson executor at a time.</p>
<p><strong>Coverage and static analysis</strong><br />
You can get coverage from running flexcover and there is a flex pmd library released by adobe &#8211; there is the usual pmd offering and a cpd plugin.</p>
<p><strong>How to run it all</strong><br />
you can run it all using maven (using the flexmojo stuff) or you can roll out your own ant stuff.  Rolling out your own ant stuff is the way to go if you have a complicated dependencies system (like at my last job), otherwise if you just want to get the job done maven is probably the way to go.</p>
<p>I will attach a working example project tomorrow.</p>


<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://blog.eamonnfaherty.co.uk/2011/02/15/unit-testing-in-actionscript3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Actionscript3 TDD: A Little More Terminology</title>
		<link>http://blog.eamonnfaherty.co.uk/2009/11/22/actionscript3-tdd-a-little-more-terminology/</link>
		<comments>http://blog.eamonnfaherty.co.uk/2009/11/22/actionscript3-tdd-a-little-more-terminology/#comments</comments>
		<pubDate>Mon, 23 Nov 2009 00:00:19 +0000</pubDate>
		<dc:creator>eamonn</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[flashtdd]]></category>
		<category><![CDATA[tdd]]></category>

		<guid isPermaLink="false">http://blog.eamonnfaherty.co.uk/?p=260</guid>
		<description><![CDATA[This is the last blog post I plan to make about the terminology around TDD. There will be real life examples from now on. I have previously discussed the terms collaborators, subject under test (SUT) and test doubles. Here, I am going to describe the three types of test doubles you can use. The Real Thing If you have a simple collaborator which only really stores and retrieves values, like a model, then is it worth replacing it for testing purposes? I personally think as long as this collaborator is unit tested then it is okay. Once there is someRead more


No related posts.

Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>This is the last blog post I plan to make about the terminology around TDD. There will be real life examples from now on.<br />
I have previously discussed the terms collaborators, subject under test (SUT) and test doubles.  Here, I am going to describe the three types of test doubles you can use.</p>
<p><strong>The Real Thing</strong><br />
If you have a simple collaborator which only really stores and retrieves values, like a model, then is it worth replacing it for testing purposes?  I personally think as long as this collaborator is unit tested then it is okay.  Once there is some logic in the collaborator, some mutator methods, then I think you must refactor your unit tests and use a proper test double.</p>
<p><strong>Stubs</strong><br />
Stubs are replacements for collaborators with pre-programmed responses for requests and fields that store inputs:</p>
<pre class="brush:as3">public function get username():String {
    return "eamonn";
}
public function set username(username:String):void {
    _usernameSetDuringTest = username;
}</pre>
<p>The first method does two important things.  It makes your code deterministic.  Your collaborator will always return &#8220;eamonn&#8221; as a username. It also means that the only complicated thing is your subject under test.  Both of these things are very important for unit testing code.<br />
The second method stores the input sent to the object.  The field _usernameSetDuringTest can be queried later to find out if the test should pass or fail.</p>
<p><strong>Mocks</strong><br />
Mocks are objects setup to expect interactions.  When you use a mock you define which methods on it should be called and which parameters it expects.  You run your test code and then you verify that the mock has been interacted with in the way you thought it should have been.</p>
<p><strong>My Thoughts</strong><br />
From my experience I have found mocks to be very frustrating.  Unit tests that use mocks are more tightly coupled to the production code and this makes refactoring harder.<br />
If I rename the method in the example above I have the following changes:<br />
<em>If using a mock, I would change the name of the method in the real collaborator, the test double and in the unit test as it would be listed as a method that should be called.</em><br />
or<br />
<em>If using a stub, I would change the name of the method in the real collaborator and in the test double</em><br />
If I am using FDT and these two classes implement the same interface I can use the refactor -> rename method tool within FDT.  This handles the rename when using a stub.  It cannot currently handle the change if I had used a mock.<br />
This might seem like a lazy reason to use a stub over a mock but you will have to consider when you will be making this change.  It will probably be a very high priority bug fix needed a year after you wrote the code and you will probably want to get it resolved ASAP.  There are many other reasons to use stubs over mocks but I think you should make that decision with your team or for yourself.  <a href="http://martinfowler.com/articles/mocksArentStubs.html">Here</a> is a really good article on the differences between mocks and stubs.  It also spiders onto other good articles on other testing approaches. It is definitely worth checking out if you have the time.</p>


<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://blog.eamonnfaherty.co.uk/2009/11/22/actionscript3-tdd-a-little-more-terminology/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

