<?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>HCoder.org &#187; tests</title>
	<atom:link href="http://hcoder.org/tag/tests/feed/" rel="self" type="application/rss+xml" />
	<link>http://hcoder.org</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Sat, 04 Feb 2012 11:06:44 +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>LeakFeed and &lt;angular/&gt;</title>
		<link>http://hcoder.org/2011/09/15/angular/</link>
		<comments>http://hcoder.org/2011/09/15/angular/#comments</comments>
		<pubDate>Thu, 15 Sep 2011 20:37:35 +0000</pubDate>
		<dc:creator>emanchado</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[Freedom]]></category>
		<category><![CDATA[angular]]></category>
		<category><![CDATA[automated tests]]></category>
		<category><![CDATA[bootstrap]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[jasmine]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[tdd]]></category>
		<category><![CDATA[tests]]></category>

		<guid isPermaLink="false">http://hcoder.org/?p=1128</guid>
		<description><![CDATA[A couple of week ago I discovered LeakFeed, an API to fetch cables from Wikileaks. I immediately thought it would be cool to play a bit with it and create some kind of application. After a couple of failed ideas that didn&#8217;t really take off, I decided to exploit my current enthusiasm for Javascript and [...]]]></description>
			<content:encoded><![CDATA[<p>A couple of week ago I discovered <a href="http://www.leakfeed.com/">LeakFeed</a>, an API to fetch cables from <a href="http://www.wikileaks.org/">Wikileaks</a>. I immediately thought it would be cool to play a bit with it and create some kind of application. After a couple of failed ideas that didn&#8217;t really take off, I decided to exploit my current enthusiasm for Javascript and build something without a server. Other advantages were that I knew <a href="http://angularjs.org/">Angular</a>, an HTML &#8220;power up&#8221; written in Javascript (what else?), which I knew it would ease the whole process a lot, and I even got the chance to learn how to use Twitter&#8217;s excellent <a href="http://twitter.github.com/bootstrap/">Bootstrap</a> HTML and CSS toolkit.</p>
<p>What I decided to build is a very simple interface to search for leaked cables. I called it <a href="http://emanchado.github.com/leakyleaks.html">LeakyLeaks</a> (see the <a href="https://github.com/emanchado/LeakyLeaks">code on GitHub</a>). Unfortunately the LeakFeed API is quite limited, so I had to limit my original idea. However, I think the result is kind of neat, especially considering the little effort. To build it, I started writing support classes and functions using Test-Driven Development with <a href="http://pivotal.github.com/jasmine/">Jasmine</a>. Once I had that basic functionality up and running I started building the interface with Bootstrap and, at that point, integrating the data from LeakFeed with Angular was so easy it&#8217;s almost ridiculous. And as LeakFeed can return the data using JSONP, I didn&#8217;t even need a server: all my application is simply a <em>static</em> HTML file with some Javascript code.</p>
<p>All this get-data-from-somewhere-and-display-it is astonishingly simple in Angular. There&#8217;s this functionality (&#8220;<a href="http://docs.angularjs.org/#!/api/angular.service.$resource">resources</a>&#8220;) to declare sources of external data: you define the URLs and methods to get the data from those resources, and then simply call some methods to fetch the data. E.g.: you can get the list of all tags in LeakFeed from <a href="http://api.leakfeed.com/v1/cables/tags.json">http://api.leakfeed.com/v1/cables/tags.json</a> (adding a GET parameter <code>callback</code> with a function name if you want <a href="http://en.wikipedia.org/wiki/JSONP">JSONP</a>). Similarly, you can get the list of all offices in LeakFeed from <a href="http://api.leakfeed.com/v1/cables/offices.json">http://api.leakfeed.com/v1/cables/offices.json</a>. In Angular, you can declare a resource to get all this information like this:</p>
<pre class="syntax javascript">this.LeakFeedResourceProxy = $resource(
 'http://api.leakfeed.com/v1/cables/:id.json',
 { callback: 'JSON_CALLBACK' },
 { getTags:    {method: 'JSON', isArray: true, params: {id: 'tags'}},
   getOffices: {method: 'JSON', isArray: true, params: {id: 'offices'}}}
);</pre>
<p>Once you have declared it, using it is as simple as calling the appropriate method on the object. That is, you can get the tags by calling <code class="syntax javascript">this.LeakFeedResourceProxy.getTags()</code>, and the offices by calling <code class="syntax javascript">this.LeakFeedResourceProxy.getOffices()</code>. And when I say &#8220;get the tags&#8221;, I mean <em>get a list of Javascript objects</em>: no JSON, text or processing involved. If you assign the result of those functions to any property (say, <code class="syntax javascript">this.availableOffices</code>), you&#8217;ll be able to show that information like so (the <code class="syntax javascript">|officename</code> is a custom filter to show the office names with a special format):</p>
<pre class="syntax html">&lt;select id=&quot;office&quot; name=&quot;office&quot;&gt; \
  &lt;option value=&quot;{{o.name}}&quot;&gt;{{o.display_name|officename}} ({{o.cables}})&lt;/option&gt; \
&lt;/select&gt;</pre>
<p>The cool thing is, thanks to Angular&#8217;s data binding, anytime the value of that variable changes, the representation in the HTML changes, too. That is, if you assign another value to <code class="syntax javascript">this.availableOffices</code> the select box will be automatically updated to have the new set of options! But the data binding is two-way, so any changes you make in the UI also get reflected back in the Javascript variables. This further simplifies many tasks and makes programming with Angular a breeze.<br />
There are other nice things about Angular (and many nice things about Bootstrap and Jasmine of course!), but I think that&#8217;s enough for today :-)</p>
 <p><a href="http://hcoder.org/?flattrss_redirect&amp;id=1128&amp;md5=15fac2e864cbc672f9ea3fd3b8c15bc4" title="Flattr" target="_blank"><img src="http://hcoder.org/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://hcoder.org/2011/09/15/angular/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<atom:link rel="payment" href="http://hcoder.org/?flattrss_redirect&amp;id=1128&amp;md5=15fac2e864cbc672f9ea3fd3b8c15bc4" type="text/html" />
	</item>
		<item>
		<title>From pseudo-code to code</title>
		<link>http://hcoder.org/2010/08/10/from-pseudo-code-to-code/</link>
		<comments>http://hcoder.org/2010/08/10/from-pseudo-code-to-code/#comments</comments>
		<pubDate>Tue, 10 Aug 2010 20:45:16 +0000</pubDate>
		<dc:creator>emanchado</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[Work]]></category>
		<category><![CDATA[automated tests]]></category>
		<category><![CDATA[science]]></category>
		<category><![CDATA[testability]]></category>
		<category><![CDATA[testing]]></category>
		<category><![CDATA[tests]]></category>

		<guid isPermaLink="false">http://hcoder.org/?p=416</guid>
		<description><![CDATA[This post is probably not about what you&#8217;re thinking. It&#8217;s actually about automated testing. Different stuff I&#8217;ve been reading or otherwise been exposed to in the last weeks has made me reach a sort of funny comparison: code is (or can be) like science. You come up with some &#8220;theory&#8221; (your code) that explains something [...]]]></description>
			<content:encoded><![CDATA[<p><em>This post is probably not about what you&#8217;re thinking. It&#8217;s actually about automated testing.</em></p>
<p>Different stuff I&#8217;ve been reading or otherwise been exposed to in the last weeks has made me reach a sort of funny comparison: code is (or can be) like science. You come up with some &#8220;theory&#8221; (your code) that explains something (solves a problem)&#8230; and you make sure you can <em>measure</em> it and <em>test</em> it for people to believe your theory and build on top of it.</p>
<p>I mean, something claiming to be science that can&#8217;t be easily measured, compared or peer-reviewed would be ridiculous. Scientists wouldn&#8217;t believe in it and would certainly not build anything on top of it because the foundation is not reliable.</p>
<p>I claim that software should be the same way, and thus it&#8217;s ridiculous to trust software that doesn&#8217;t have a good test suite, or even worse, that may not even be particularly testable. Trusting software without a test suite is not <em>that</em> different from taking the word of the developer that it &#8220;works on my machine&#8221;. Scientists would call untested science <em>pseudo-science</em>, so <em>I</em> am tempted to call code without tests <em>pseudo-code</em>.</p>
<p>Don&#8217;t get me wrong: sure you can test by hand, and hand-made tests are useful and necessary, but that only proves that the exact code you tested, without any changes, works as expected. But you know what? <em>Software changes all the time</em>, so that&#8217;s not a great help. If you don&#8217;t have a way to <strong>quickly</strong> and <strong>reliably</strong> measure how your code behaves, <em>every time you make a change</em> you are taking a leap of faith. And the more leaps of faith you take, the less credible your code is.</p>
 <p><a href="http://hcoder.org/?flattrss_redirect&amp;id=416&amp;md5=8e86f84ff69bb4fefc237936a785bd85" title="Flattr" target="_blank"><img src="http://hcoder.org/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://hcoder.org/2010/08/10/from-pseudo-code-to-code/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<atom:link rel="payment" href="http://hcoder.org/?flattrss_redirect&amp;id=416&amp;md5=8e86f84ff69bb4fefc237936a785bd85" type="text/html" />
	</item>
		<item>
		<title>Feeling the pressure produces better code?</title>
		<link>http://hcoder.org/2009/12/06/feeling-the-pressure-produces-better-code/</link>
		<comments>http://hcoder.org/2009/12/06/feeling-the-pressure-produces-better-code/#comments</comments>
		<pubDate>Sun, 06 Dec 2009 16:10:00 +0000</pubDate>
		<dc:creator>emanchado</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[automated]]></category>
		<category><![CDATA[exploratory]]></category>
		<category><![CDATA[qa]]></category>
		<category><![CDATA[teams]]></category>
		<category><![CDATA[testing]]></category>
		<category><![CDATA[tests]]></category>
		<category><![CDATA[unit]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[The other day I was in a conversation with some developer that was complaining about some feature. He claimed that it was too complex and that it had led to tons of bugs. In the middle of the conversation, the developer said that the feature had been so buggy that he ended up writing a [...]]]></description>
			<content:encoded><![CDATA[<p>The other day I was in a conversation with some developer that was complaining about some feature. He claimed that it was too complex and that it had led to tons of bugs. In the middle of the conversation, the developer said that the feature had been so buggy that he ended up writing a lot of unit tests for it. To be honest I don&#8217;t think there were a lot of bugs <em>after</em> those tests were written, so that made me think:</p>
<blockquote><p>Maybe the testers in his team are doing too good of a job?</p></blockquote>
<p>
Because, you know, if testers are finding enough of &#8220;those bugs&#8221; (the ones that should be caught and controlled by unit tests and not by testers <em>weeks</em> after the code was originally written), maybe some developers are just not &#8220;feeling the pressure&#8221; and can&#8217;t really get that they should be writing tests for their code. If testers are very good, things just work out fine in the end&#8230; sort of. And of course, the problem here is the trailing &#8220;sort of&#8221;.<br />
I know I&#8217;m biased, but in my view there is a <strong>ton</strong> of bugs that should never be seen by someone that is not the developer itself. Testers should deal with more complex, interesting, user-centred bugs. Non-trivial cases. Suboptimal UIs. Implementation disagreements between developers and stakeholders. That kind of thing. It&#8217;s simply a waste of time and resources that testers have to deal with silly, easy-to-avoid bugs on a daily basis. Not to mention that teams shouldn&#8217;t have to wait for days or weeks until they find <em>basic</em> bugs via exploratory testing. Or that a lot of those are much, much quicker to test with unit tests than having to create the whole fixture/environment for them to be found with exploratory testing.<br />
My current conclusion is that pushing on the UI/usability side is not only good for the user, but it&#8217;s likely to produce better code as it will be, on average, more complex and will have to be better controlled by QA (code review, less ad-hoc design, &#8230;) and automated tests. Maybe developers will start hating me for that, but hopefully <em>users</em> will thank me.</p>
 <p><a href="http://hcoder.org/?flattrss_redirect&amp;id=81&amp;md5=51f8ccaa005170cc7a643f0cb4c2a30c" title="Flattr" target="_blank"><img src="http://hcoder.org/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://hcoder.org/2009/12/06/feeling-the-pressure-produces-better-code/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<atom:link rel="payment" href="http://hcoder.org/?flattrss_redirect&amp;id=81&amp;md5=51f8ccaa005170cc7a643f0cb4c2a30c" type="text/html" />
	</item>
		<item>
		<title>Slides for several talks now published</title>
		<link>http://hcoder.org/2009/09/20/slides-for-several-talks-now-published/</link>
		<comments>http://hcoder.org/2009/09/20/slides-for-several-talks-now-published/#comments</comments>
		<pubDate>Sun, 20 Sep 2009 15:25:00 +0000</pubDate>
		<dc:creator>emanchado</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[Other]]></category>
		<category><![CDATA[automated]]></category>
		<category><![CDATA[courses]]></category>
		<category><![CDATA[packaging]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[slides]]></category>
		<category><![CDATA[talks]]></category>
		<category><![CDATA[testing]]></category>
		<category><![CDATA[tests]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[I had said that I was going to publish the slides for a couple of talks I had given over the last couple of months, and I just got around to actually do it, so here they are: Software automated testing 123, an entry-level talk about software automated testing. Why you should be doing it [...]]]></description>
			<content:encoded><![CDATA[<p>I had said that I was going to publish the slides for a couple of talks I had given over the last couple of months, and I just got around to actually do it, so here they are:</p>
<ul>
<li><a href="http://www.demiurgo.org/charlas/testing-123/">Software automated testing 123</a>, an entry-level talk about software automated testing. Why you should be doing it (if you&#8217;re not already), some advice for test writing, some basic concepts and some basic examples (in Perl, but I trust it shouldn&#8217;t be too hard to follow even if you don&#8217;t know the language).</li>
<li><a href="http://www.demiurgo.org/charlas/python-unittesting/">Taming the Snake: Python unit tests</a>, another entry-level talk, but this time about Python unit testing specifically. How to write xUnit style tests with <code>unittest</code>, some advice and conventions and some notes on how to use the excellent <code>nosetests</code> tool.</li>
<li>Introduction to Debian packaging, divided in four sessions: <a href="http://www.demiurgo.org/charlas/debian/1-introduction/slides.html">Introduction</a>, <a href="http://www.demiurgo.org/charlas/debian/2-simple_packaging/slides.html">Packaging a simple app</a>, <a href="http://www.demiurgo.org/charlas/debian/3-backporting_software/slides.html">Backporting software</a> and <a href="http://www.demiurgo.org/charlas/debian/4-packaging_tools/slides.html">Packaging tools</a>.</li>
</ul>
<p>Just a quick note about them: the slides shouldn&#8217;t be too hard to understand without me talking, but of course you&#8217;ll lose some stuff that is not written down, some twists, clarifications of what I mean exactly by different things and whatnot. In particular, the &#8220;They. don&#8217;t. make. sense. Don&#8217;t. write. them&#8221; stuff refers to tests that don&#8217;t have a reliable/controlled environment to run into. I feel really strong about them, so I wanted to dedicate a few more seconds to smashing the idea that they&#8217;re ok, hence the extra slides :-)</p>
<p>Enjoy them, and please send me any comments you have about them!</p>
 <p><a href="http://hcoder.org/?flattrss_redirect&amp;id=78&amp;md5=3d3c7f5943c585db1237d52f7f0d5504" title="Flattr" target="_blank"><img src="http://hcoder.org/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://hcoder.org/2009/09/20/slides-for-several-talks-now-published/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<atom:link rel="payment" href="http://hcoder.org/?flattrss_redirect&amp;id=78&amp;md5=3d3c7f5943c585db1237d52f7f0d5504" type="text/html" />
	</item>
		<item>
		<title>More Haberdasher: testsuites and RemixUI</title>
		<link>http://hcoder.org/2008/03/13/more-haberdasher-testsuites-and-remixui/</link>
		<comments>http://hcoder.org/2008/03/13/more-haberdasher-testsuites-and-remixui/#comments</comments>
		<pubDate>Thu, 13 Mar 2008 23:19:00 +0000</pubDate>
		<dc:creator>emanchado</dc:creator>
				<category><![CDATA[haberdasher]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[foton]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[rails2]]></category>
		<category><![CDATA[remixui]]></category>
		<category><![CDATA[selenium]]></category>
		<category><![CDATA[tests]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[After porting Haberdasher to Rails 2, I had forgotten to execute all the testsuites I had (unit, functional and acceptance, with Selenium and Selenium on Rails). The bad news is that they didn&#8217;t pass. The good news is that it wasn&#8217;t such a big problem making them pass again. The functional tests failed because of [...]]]></description>
			<content:encoded><![CDATA[<p>After porting <a href="http://haberdasherhq.org/">Haberdasher</a> to Rails 2, I had forgotten to execute all the testsuites I had (unit, functional and acceptance, with <a href="http://selenium.openqa.org/">Selenium</a> and <a href="http://selenium-on-rails.openqa.org/">Selenium on Rails</a>). The bad news is that they didn&#8217;t pass. The good news is that it wasn&#8217;t such a big problem making them pass again.</p>
<p>The functional tests failed because of some stupid change in Rails 2. Namely, it seems that now you can&#8217;t make more than one request in a single functional test method (bug?). The acceptance tests had some minor problems due to some changes I made in the interface. The rest worked without problems.</p>
<p>Now that everything is ported and working like a charm, it&#8217;s time to make some interesting changes. I had been wanting to use a really cool library called RemixUI, made by my former company, <a href="http://www.foton.es/">Fotón Sistemas Inteligentes</a>, and these days I finally had the chance to use the latest version. RemixUI is a &#8220;web widget&#8221; library, similar to DJWidgets, MCWidgets and RemixWidgets (all of them available in the <a href="http://fotonsi.berlios.de/">Fotón BerliOS page</a>, but unfortunately obsolete), that makes it much easier to write validation, integration between client side and server side, interface improvements with Javascript, reusable widgets/controls, etc.</p>
<p>I haven&#8217;t used it that much yet, but I&#8217;m really eager to change all the forms and controls in the application to take advantage of the cool stuff offered by RemixUI. The problem now is that the RemixUI gem is not public yet, so I can&#8217;t really release the new version of Haberdasher. I&#8217;ll try to make them put the Gem somewhere public, so I can release Haberdasher, and other people can have a look at RemixUI.</p>
 <p><a href="http://hcoder.org/?flattrss_redirect&amp;id=18&amp;md5=5a17b694a7e5b42cfe5dd6ab82404aa3" title="Flattr" target="_blank"><img src="http://hcoder.org/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://hcoder.org/2008/03/13/more-haberdasher-testsuites-and-remixui/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<atom:link rel="payment" href="http://hcoder.org/?flattrss_redirect&amp;id=18&amp;md5=5a17b694a7e5b42cfe5dd6ab82404aa3" type="text/html" />
	</item>
	</channel>
</rss>

