<?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>Platformability &#187; Ajax Testing</title>
	<atom:link href="http://blog.caplin.com/tag/ajax-testing/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.caplin.com</link>
	<description>Single Dealer Platforms, Industry Expertise</description>
	<lastBuildDate>Fri, 03 Feb 2012 15:38:56 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Benchmarking Liberator to 100,000 users</title>
		<link>http://blog.caplin.com/2010/05/14/benchmarking-liberator-to-100000-users/</link>
		<comments>http://blog.caplin.com/2010/05/14/benchmarking-liberator-to-100000-users/#comments</comments>
		<pubDate>Fri, 14 May 2010 12:51:52 +0000</pubDate>
		<dc:creator>Martin Tyler</dc:creator>
				<category><![CDATA[QA]]></category>
		<category><![CDATA[Real-time web]]></category>
		<category><![CDATA[Ajax Testing]]></category>
		<category><![CDATA[Comet]]></category>

		<guid isPermaLink="false">http://blog.caplin.com/?p=2390</guid>
		<description><![CDATA[As I mentioned on my previous blog &#8211; Comet Servers for a Single-Dealer Platform (SDP) I am performing some new benchmarks for Liberator. These are going to focus on some new things as well as some new figures for our traditional scenarios. Amongst the new benchmarks will be some tests...]]></description>
			<content:encoded><![CDATA[<p>As I mentioned on my previous blog &#8211; <a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2Jsb2cuY2FwbGluLmNvbS8yMDEwLzA0LzI3L2NvbWV0LXNlcnZlcnMtZm9yLWEtc2luZ2xlLWRlYWxlci1wbGF0Zm9ybS1zZHAv">Comet Servers for a Single-Dealer Platform (SDP)</a> I am performing some new benchmarks for Liberator. These are going to focus on some new things as well as some new figures for our traditional scenarios.</p>
<p>Amongst the new benchmarks will be some tests for publishing from the client, which is key for trading applications, and also benchmarking our container objects. A container is an object that represents a dynamic list of references to other data. Subscribing to the container automatically subscribes the client to its contents. Containers also allow you to subscribe to a subset, allowing efficient display of huge lists. The platform allows containers to be created dynamically based on filter and/or sort criteria too.<br />
<span id="more-2390"></span><br />
Anyway, back to the core benchmarks. At Caplin we have never had a customer really need more than the 30,000 client limit Liberator imposed so I never pushed it further than that. When Richard Jones blogged about <a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5tZXRhYnJldy5jb20vYXJ0aWNsZS9hLW1pbGxpb24tdXNlci1jb21ldC1hcHBsaWNhdGlvbi13aXRoLW1vY2hpd2ViLXBhcnQtMS8=">A Million-user Comet Application with Mochiweb</a> I was intrigued. Richards use case was very different to ours, but I wondered whether Liberator would handle that kind of profile. Later on <a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5taWdyYXRvcnkucm8v">Migratory</a> published some <a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5taWdyYXRvcnkucm8vZGF0YS9NaWdyYXRvcnlQdXNoU2VydmVyQmVuY2htYXJrcy5wZGY=">benchmarks</a> which used our scenarios as a base, but pushed the user numbers higher than we had done.</p>
<p>The hardest part of testing high numbers of users is actually the client side, the machines you need, or tricks you have to make, to get that many connections to your server. I removed the hard coded 30,000 limit from Liberator and set about pushing the user numbers higher.</p>
<p>Deterministic latency can be more important that the absolute value, which is why this new data is so important &#8211; <a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5zb2xhY2VzeXN0ZW1zLmNvbS8=">Solace Systems</a> talked about <a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5zb2xhY2VzeXN0ZW1zLmNvbS9zb2x1dGlvbnMvZmluYW5jaWFsLXNlcnZpY2VzL2xhdGVzdC1maW5hbmNpYWwtbWVtZS1jb25zaXN0ZW50LWxhdGVuY3k=">Consistent Latency</a> recently. Something I was never happy about with our old benchmarks was they just showed average latency, which is good, but are all messages the same? How much longer do some take? What is the worst case? If you are trading and you get a message that is the worst case latency then that is important to you. So with my latest rig I am measuring min/max latency as well as standard deviation.  Both these are represented by error bars on the graph below. Another change is we are now measuring in microseconds and focussing on minimum, but consistent, latency as much as possible.</p>
<p>So here is a taster of the results I am getting. I have pushed it up to 100,000 users. The Liberator is running on a 2x Quad core Opteron box, which was barely breaking sweat, the client machines are what stopped me going past 100,000.</p>
<p><a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2Jsb2cuY2FwbGluLmNvbS93cC1jb250ZW50L3VwbG9hZHMvbG93X3VwZGF0ZXNfMTAway5wbmc="><img class="alignnone size-medium wp-image-2391" title="low_updates_100k" src="http://blog.caplin.com/wp-content/uploads/low_updates_100k-300x225.png" alt="" width="300" height="225" /></a></p>
<p>As you can see, the latency is very low. At 100,000 users average latency is still only 6ms. The red max bars show the worst case hits 30ms for one sample, but standard deviation is very small. Each sample ran for 30 seconds, so at 100,000 clients, 3 million messages were measured with the worst being 26ms. If you could zoom in on the start of the graph you would see than 10,000 users can receive 1 message/sec with latency of less than 1ms!</p>
<p>Remember, these are benchmarks, in the real world over the Internet, things will be different &#8211; but you have to start with a good base!</p>
<p>I might publish some further graphs as I test the scenarios with higher message rates.</p>
 <img src="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=2390" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://blog.caplin.com/2010/05/14/benchmarking-liberator-to-100000-users/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The beauty of small tests</title>
		<link>http://blog.caplin.com/2010/04/15/the-beauty-of-small-tests/</link>
		<comments>http://blog.caplin.com/2010/04/15/the-beauty-of-small-tests/#comments</comments>
		<pubDate>Thu, 15 Apr 2010 11:53:35 +0000</pubDate>
		<dc:creator>Andrew Darnell</dc:creator>
				<category><![CDATA[QA]]></category>
		<category><![CDATA[Agile]]></category>
		<category><![CDATA[Ajax Testing]]></category>
		<category><![CDATA[Dev Tips]]></category>
		<category><![CDATA[Software Engineering]]></category>
		<category><![CDATA[Test Driven Development]]></category>
		<category><![CDATA[Unit Testing]]></category>

		<guid isPermaLink="false">http://blog.caplin.com/?p=1342</guid>
		<description><![CDATA[When tests are small, a test failure means just one thing – somewhere in these ten lines of code which are being tested, there is an error.  Ok, sometimes this can mean that there is an error in the test script, or a there is a failure, or change of...]]></description>
			<content:encoded><![CDATA[<p>When tests are small, a test failure means just one thing – somewhere in these ten lines of code which are being tested, there is an error.  Ok, sometimes this can mean that there is an error in the test script, or a there is a failure, or change of expectation, but fundamentally, it pin-points the cause of the failure to a <strong>small</strong> target, which usually means that debugging becomes <strong>trivial</strong>.</p>
<p>When an end to end acceptance test fails, the failure could be due to any one of a large number of source lines or expectations changes across a large body of code.  Debugging may be quick, but often isn&#8217;t.</p>
<p><span id="more-1342"></span></p>
<p>Small tests run faster too! While a typical small test may take 10 milliseconds to run, a large acceptance test may take twenty minutes.</p>
<p>Just a small back of the envelope calculation tells us that if a developer checks in twice a day and saves an hour each time because potential issues had been found before check-in with fast small tests, and the faster feedback, or has reduced their time spent debugging &#8211; that is two hours a day per developer that could be put to better use.</p>
<blockquote><p>2 hours a day * thirty developers * two working weeks = <strong>600 additional hours</strong> per two week iteration available.</p></blockquote>
<p>This is equivalent to adding seven and a half developers to the team!</p>
<p><strong>What value do you get from tests of different sizes?</strong></p>
 <img src="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=1342" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://blog.caplin.com/2010/04/15/the-beauty-of-small-tests/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SPA 2010 conference proposals</title>
		<link>http://blog.caplin.com/2009/11/04/spa-2010-conference-proposals/</link>
		<comments>http://blog.caplin.com/2009/11/04/spa-2010-conference-proposals/#comments</comments>
		<pubDate>Wed, 04 Nov 2009 16:53:29 +0000</pubDate>
		<dc:creator>Patrick Myles</dc:creator>
				<category><![CDATA[Events]]></category>
		<category><![CDATA[Agile]]></category>
		<category><![CDATA[Ajax Testing]]></category>
		<category><![CDATA[Comet]]></category>
		<category><![CDATA[Real-time web]]></category>
		<category><![CDATA[Software Engineering]]></category>
		<category><![CDATA[User Experience]]></category>
		<category><![CDATA[UX]]></category>

		<guid isPermaLink="false">http://blog.caplin.com/?p=562</guid>
		<description><![CDATA[The SPA conference is always a great event with lots of interesting sessions and a good mix of people in attendence. Following a succesful session that Andrew MacLeod and I ran at last year&#8217;s conference (building an automated browser testing framework using Selenium), a couple of proposals have been put...]]></description>
			<content:encoded><![CDATA[<p>The <a  0="title="SPA" 1="2010"" href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5zcGFjb25mZXJlbmNlLm9yZy9zcGEyMDEwLw==" 2="target="_blank"">SPA conference</a> is always a great event with lots of interesting sessions and a good mix of people in attendence.</p>
<p>Following a succesful session that Andrew MacLeod and I ran at last year&#8217;s conference (<a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2Jsb2cuY2FwbGluLmNvbS8yMDA5LzA0LzE1L3NwYS0yMDA5LWNvbmZlcmVuY2UtdGVzdGluZy1hamF4LWFwcGxpY2F0aW9ucy10aHJvdWdoLXRoZS1ndWkvI21vcmUtMTc3" 0="target="_blank"">building an automated browser testing framework using Selenium</a>), a couple of proposals have been put in by Caplin&#8217;s staff for next year&#8217;s conference in May:</p>
<p>Sarah Lawfull and <a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2Jsb2cuY2FwbGluLmNvbS9hdXRob3IvZHVuY2FuYmNhcGxpbmNvbS8=">Duncan Brown</a> have proposed <strong>&#8220;Persona-driven development – can it work for you?&#8221;.</strong></p>
<p><a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2Jsb2cuY2FwbGluLmNvbS9hdXRob3IvYWRhbWljYXBsaW5jb20v">Adam Iley</a> and <a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2Jsb2cuY2FwbGluLmNvbS9hdXRob3IvcGhpbGxjYXBsaW5jb20v">Phil Leggetter</a> have proposed <strong>&#8220;Comet, Twitter and the Real-Time Web&#8221;</strong></p>
<p>Fingers crossed they&#8217;ll be accepted &#8211; if they are we&#8217;ll post some more info on the contents nearer the time.</p>
 <img src="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=562" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://blog.caplin.com/2009/11/04/spa-2010-conference-proposals/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Silverlight for single dealer portals?</title>
		<link>http://blog.caplin.com/2009/06/09/silverlight-for-single-dealer-portals/</link>
		<comments>http://blog.caplin.com/2009/06/09/silverlight-for-single-dealer-portals/#comments</comments>
		<pubDate>Tue, 09 Jun 2009 10:35:13 +0000</pubDate>
		<dc:creator>Patrick Myles</dc:creator>
				<category><![CDATA[Trading Technology]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[Ajax Testing]]></category>
		<category><![CDATA[Financial Ajax]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Real-time web]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Software Engineering]]></category>

		<guid isPermaLink="false">http://blog.caplin.com/?p=243</guid>
		<description><![CDATA[Could it be that the time for Silverlight in finance has come? Does Adobe Flex solve any of the complexities of building web applications? Where does Caplin Trader fit in to this landscape? These are all questions that I am hearing (and asking) increasingly at the moment &#8211; so here&#8217;s...]]></description>
			<content:encoded><![CDATA[<p>Could it be that the time for Silverlight in finance has come? Does <a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5hZG9iZS5jb20vcHJvZHVjdHMvZmxleC8=">Adobe Flex</a> solve any of the complexities of building web applications? Where does <a  0="title="Caplin" 1="Trader"" href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5jYXBsaW4uY29tL2NhcGxpbnRyYWRlci8=">Caplin Trader</a> fit in to this landscape? These are all questions that I am hearing (and asking) increasingly at the moment &#8211; so here&#8217;s how I see it&#8230;</p>
<p><img class="alignright" title="Silverlight" src="http://i16.photobucket.com/albums/b12/al_oasis1/microsoft_silverlight.jpg" alt="" width="280" height="312" /></p>
<p>There has been a big push from Adobe towards using Flex (and to a lesser extent<a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5hZG9iZS5jb20vcHJvZHVjdHMvbGl2ZWN5Y2xlL2RhdGFzZXJ2aWNlcy8=" 0="target="_blank""> LiveCycle Data Services</a> &#8211; their messaging product) for trading portals and you can certainly build a flashy offering, as can be seen in the recent launch of Morgan Stanley&#8217;s <a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5tb3JnYW5zdGFubGV5LmNvbS9tYXRyaXhpbmZvLw==">Matrix</a>.</p>
<p>But questions still remain over the ease of development and deployment of such a large-scale enterprise application, and though the Flex Builder seems to make this easier, digging beneath the surface can make for a frustrating experience, as <a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2NvZGVydHJvbi5ibG9nc3BvdC5jb20vMjAwOS8wNS9mbGV4LTMtdmVyc3VzLXNpbHZlcmxpZ2h0LTMtaW4uaHRtbA==">Alex Vandeberg&#8217;s excellent analysis</a> recently described.</p>
<p>Could Silverlight be an answer to this?</p>
<p><span id="more-243"></span></p>
<p><a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5jYXBsaW4uY29tL2NhcGxpbnRyYWRlcg==">Caplin Trader</a> is Caplin&#8217;s toolkit and platform for building trading portals, in production at a number of banks. The client-side framework is built in Ajax (the browser&#8217;s native presentation technology), though we allow and encourage the embedding of content in any RIA techology &#8211; be that HTML, Ajax, Flash/Flex, Silverlight (and even Java Applets if you are still that way inclined!). I believe that this approach encourages building a best-of-breed portal: You use Caplin&#8217;s APIs and the browser&#8217;s native language for the container and most pricing and trading components, but where appropriate (for example rich media, 3D, vector graphics) you have the freedom to seamlessly embed a more suitable technology such as Flex or Silverlight. In addition you can leverage existing web content with minimal effort. The alternative approach of using one of these proprietary plugins for the container makes it very hard to embed anything else within the container.</p>
<p>Caplin Trader is built on top of the <a  0="title="Caplin" 1="Platform"" href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5jYXBsaW4uY29tL2NhcGxpbnBsYXRmb3Jt" 2="target="_blank"">Caplin Platform</a> &#8211; a generic financial client-connectivity, web messaging and trading layer. Caplin have always provided client APIs for a variety of languages (Java, .Net, Ajax, C++ currently) to allow people to either integrate with existing applications or build their own from scratch (usually where Caplin Trader isn&#8217;t suitable or desired).</p>
<p>What is interesting is the growing demand for <a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3NpbHZlcmxpZ2h0Lm5ldC8=" 0="target="_blank"">Silverlight</a> as a client-side target for Caplin&#8217;s technology. I know of at least 3 large investment banks that are kicking off projects targetted at Silverlight. Whilst not yet cross-asset single dealer portals on the same scale as Matrix (or most of the Caplin Trader projects), it&#8217;s interesting that they&#8217;ve bitten the bullet despite lingering doubts over adoption rates and install base (&lt;30% as of today at <a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5yaWFzdGF0cy5jb20vIw==" 0="target="_blank"">riastats.com</a>), though Microsoft would like you to think <a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2Jsb2dzLm1zZG4uY29tL21pa2Vvcm1vbmQvYXJjaGl2ZS8yMDA5LzAyLzI3L3NpbHZlcmxpZ2h0LWFkb3B0aW9uLWEtZmV3LW51bWJlcnMuYXNweA==" 0="target="_blank"">otherwise</a>!</p>
<p>If it can gain momentum, Silverlight will quickly eclipse (no pun intended) Flex as a developers&#8217; platform of choice, at least in terms of true software engineering tools and developer productivity. Whilst we&#8217;ve done a lot of work to build developer tools and structure our APIs to &#8216;tame&#8217; Ajax and JavaScript, neither Ajax or Flex/ActionScript will catch up with C# any time soon when it comes to more advanced activities such as IDEs with truly integrated build/test/debug/profile tools and refactoring, not to mention the number of existing C# developers that could transition to Silverlight easily.</p>
<p>You can already use the Caplin Platform and Caplin Trader with Silverlight by creating a bridge to our JavaScript <a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5mcmVlbGliZXJhdG9yLmNvbS9kb2N1bWVudGF0aW9uL3NsNGIvaW50cm9kdWN0aW9uLmh0bWw=" 0="target="_blank"">StreamLink for Browsers</a> library. We&#8217;ve recently built a prototype native Silverlight library, with an identical API to our existing C#/.Net offering, and we expect to be able to release a full version in July. On top of our Caplin Trader subsystems this could be used as a powerful front-end for those who choose to build single dealer portals with it and it will certainly be interesting to see who jumps first&#8230;</p>
 <img src="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=243" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://blog.caplin.com/2009/06/09/silverlight-for-single-dealer-portals/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to dynamically create a class definition for use with Mock4JS</title>
		<link>http://blog.caplin.com/2009/04/16/how-to-dynamically-create-a-class-definition-for-use-with-mock4js/</link>
		<comments>http://blog.caplin.com/2009/04/16/how-to-dynamically-create-a-class-definition-for-use-with-mock4js/#comments</comments>
		<pubDate>Thu, 16 Apr 2009 17:00:28 +0000</pubDate>
		<dc:creator>Phil Leggetter</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[Ajax Testing]]></category>
		<category><![CDATA[Mock4JS]]></category>
		<category><![CDATA[Software Engineering]]></category>
		<category><![CDATA[Test Driven Development]]></category>
		<category><![CDATA[Unit Testing]]></category>

		<guid isPermaLink="false">http://blog.caplin.com/?p=187</guid>
		<description><![CDATA[Mock4JS is a really useful unit testing helper library that allows you to create mocks of your JavaScript classes. What it doesn&#8217;t presently support is mocking of objects that you can&#8217;t create an instance of yourself using new Class() or of objects that are dynamically created and have functions appended...]]></description>
			<content:encoded><![CDATA[<p><a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL21vY2s0anMuc291cmNlZm9yZ2UubmV0Lw==">Mock4JS</a> is a really useful unit testing helper library that allows you to create mocks of your JavaScript classes. What it doesn&#8217;t presently support is mocking of objects that you can&#8217;t create an instance of yourself using <code>new Class()</code> or of objects that are dynamically created and have functions appended to them.</p>
<p><span id="more-187"></span></p>
<h3>What do I mean by not being able to &#8220;create an instance of yourself using <code>new Class()</code>&#8220;?</h3>
<pre class="javascript">MyClassDefinition = function()
{
};

MyClassDefintion.prototype.myFunction = function()
{
    // do some stuff
};
MyClassDefinition = new MyClassDefinition();</pre>
<p>Here we lose the ability to do <code>new MyClassDefinition();</code></p>
<h3>What do I mean by &#8220;objects that are dynamically created&#8221;?</h3>
<pre class="javascript">// create an object using the object literal notation
var oObj = {};

// dynamically append a function
oObj.myFunction = function()
{
    // do some stuff
};</pre>
<p>Code written in both these ways make it more difficult to create a mock using Mock4JS because it expects a function reference to be passed to the mock method call.</p>
<p>A way around this is to dynamically create a definition from the object. This is done using the following piece of code:</p>
<pre class="javascript">function createMockDefinition(oObject)
{
    var oMockedDefinition = new Function();
    for( var x in oObject )
    {
        // Only add functions to the dynamically created prototype
        if( typeof oObject[ x ] == "function" )
        {
            oMockedDefinition.prototype[x] = function(){};
        }
    }
    return oMockedDefinition;
};</pre>
<p>With the above code we have now created a class definition that we can pass to the Mock4JS <code>mock()</code> function.</p>
<pre class="javascript">function myTest()
{
    var oObjectIWantToTest = {};
    oObjectIWantToTest.functionIWantToTest = function(){};

    var oMyMockDefinition = createMockDefinition( oObjectIWantToTest );
    var oMyMock = mock( oMyMockDefinition );
    var oMyMockProxy = oMyMock.proxy();

    // setup expectations
    oMyMock.expects(once()).functionIWantToTest("myArgument");

    // call function and execute mock method.
    oMyMockProxy.functionIWantToTest("myArgument");

    // Finally, verify the expected mock methods have been called.
    // If not, an exception will be thrown.
    Mock4JS.verifyAllMocks();
};</pre>
 <img src="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=187" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://blog.caplin.com/2009/04/16/how-to-dynamically-create-a-class-definition-for-use-with-mock4js/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>SPA 2009 Conference &#8211; Testing Ajax Applications through the GUI</title>
		<link>http://blog.caplin.com/2009/04/15/spa-2009-conference-testing-ajax-applications-through-the-gui/</link>
		<comments>http://blog.caplin.com/2009/04/15/spa-2009-conference-testing-ajax-applications-through-the-gui/#comments</comments>
		<pubDate>Wed, 15 Apr 2009 17:13:34 +0000</pubDate>
		<dc:creator>Andrew MacLeod</dc:creator>
				<category><![CDATA[Events]]></category>
		<category><![CDATA[Ajax Testing]]></category>
		<category><![CDATA[Comet]]></category>
		<category><![CDATA[Software Engineering]]></category>

		<guid isPermaLink="false">http://blog.caplin.com/?p=177</guid>
		<description><![CDATA[Last week myself and Patrick Myles, Caplin&#8217;s Head of Engineering, presented a workshop session at the SPA 2009 conference on Testing Ajax Applications through the GUI. The main theme of the talk was to demonstrate that, by building a thin business-domain framework on top of Selenium and structuring test cases...]]></description>
			<content:encoded><![CDATA[<p>Last week myself and Patrick Myles, Caplin&#8217;s Head of Engineering, presented a workshop session at the <a  0="title="SPA" 1="2009" 2="conference"" href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5zcGFjb25mZXJlbmNlLm9yZw==">SPA 2009 conference</a> on Testing Ajax Applications through the GUI.</p>
<p>The main theme of the talk was to demonstrate that, by building a thin business-domain framework on top of Selenium and structuring test cases appropriately, it&#8217;s possible to construct a very simple <a  0="title="Domain" 1="Specific" 2="Language"" href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2VuLndpa2lwZWRpYS5vcmcvd2lraS9Eb21haW4tc3BlY2lmaWNfbGFuZ3VhZ2U=">DSL</a> that makes test scripts intelligible to non-programmers.</p>
<p><span id="more-177"></span></p>
<p>The workshop involved a couple of pairing exercises using the  <a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cHM6Ly9hZGRvbnMubW96aWxsYS5vcmcvZW4tVVMvZmlyZWZveC9hZGRvbi8yMDc5">Firefox Selenium IDE add-on</a> which enabled participants to get their hands dirty writing basic tests in a very short time.  I hadn&#8217;t used the Selenium  IDE much prior to the conference, but it&#8217;s a brilliantly simple record &amp; playback tool which Caplin should consider exploiting.</p>
<p>We  supplied delegates with USB keys containing <a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3BvcnRhYmxlYXBwcy5jb20vYXBwcy9pbnRlcm5ldC9maXJlZm94X3BvcnRhYmxl">Firefox Portable</a> that was pre-configured with the necessary add-ons and bookmarks.  This offered a complete client side Selenium runtime environment for all the exercises, and connected to a web-site that we hosted on a wireless LAN.  This setup was quite effective in providing a full development environment in minimal set-up time.</p>
<p>This was our first time presenting at a conference, and despite all the hours sweating over composing slides and exercises,  it was really good fun and <a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2F2YWlsYWdpbGl0eS53b3JkcHJlc3MuY29tLzIwMDkvMDQvMDkvc3BhLTIwMDktaGlnaGxpZ2h0cy8=">the session was well received</a>.  We&#8217;re very grateful to <a  href="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3B1dHRpbmd0aGV0ZWFpbnRvdGVhbS5ibG9nc3BvdC5jb20v">Ivan Moore</a> for encouraging us to put this together:  SPA is a really friendly and collaborative forum that have frequent events, and I would recommend it to anyone as a good place to cut their teeth presenting a conference session.</p>
 <img src="http://blog.caplin.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=177" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://blog.caplin.com/2009/04/15/spa-2009-conference-testing-ajax-applications-through-the-gui/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

