<?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>All Night Diner &#187; testing</title>
	<atom:link href="http://micropipes.com/blog/tag/testing/feed/" rel="self" type="application/rss+xml" />
	<link>http://micropipes.com/blog</link>
	<description>because at 3am anything sounds good</description>
	<lastBuildDate>Mon, 03 May 2010 17:34:44 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>addons.mozilla.org ♥s unit tests.  Again.</title>
		<link>http://micropipes.com/blog/2010/05/03/addons-mozilla-org-%e2%99%a5s-unit-tests-again/</link>
		<comments>http://micropipes.com/blog/2010/05/03/addons-mozilla-org-%e2%99%a5s-unit-tests-again/#comments</comments>
		<pubDate>Mon, 03 May 2010 17:34:44 +0000</pubDate>
		<dc:creator>Wil Clouser</dc:creator>
				<category><![CDATA[Mozilla]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[AMO]]></category>
		<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[Django]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://micropipes.com/blog/?p=142</guid>
		<description><![CDATA[AMO has had an on-again off-again relationship with unit tests.  A little over a year ago we had a thousand unit tests that sort of, mostly, ran.  The problem is, PHP unit testing just isn&#8217;t as good as it should be.  CakePHP relies on SimpleTest, one of the main PHP test suites. [...]]]></description>
			<content:encoded><![CDATA[<p><a href="https://addons.mozilla.org">AMO</a> has had an on-again off-again relationship with unit tests.  A little over a year ago we had <a href="http://micropipes.com/blog/2009/04/09/addonsmozillaorg-celebrates-1000-passing-unit-tests/">a thousand unit tests</a> that sort of, mostly, ran.  The problem is, PHP unit testing just isn&#8217;t as good as it should be.  CakePHP relies on <a href="http://www.simpletest.org/">SimpleTest</a>, one of the main PHP test suites.  It worked relatively well for a small number of tests, but as our suite grew, so did our troubles.</p>
<p>Our main issue was hitting a memory limit or the max execution time.  We hit the limits often for a variety of reasons, some legitimate bugs, and some because we tried to hack around things to make the tests run.  If we change the limits we affect the tests because they are running within the same environment.  There wasn&#8217;t really a concept of fixtures then, although it looks like <a href="http://bakery.cakephp.org/articles/view/testing-models-with-cakephp-1-2-test-suite">CakePHP has stepped up there</a>.  The simple test web runner was hard to use and the mock objects were sometimes a little too mocked and missing some attributes.</p>
<p>All in all it was a heroic effort to get that many tests, but we didn&#8217;t maintain it because they were so slow to write and difficult to run.  Testing can be a pain to write, sure, but it shouldn&#8217;t be a burden like that.  Enter <a href="http://docs.djangoproject.com/en/dev/topics/testing/">Django&#8217;s testing suite</a> (built on top of <a href="http://docs.python.org/library/unittest.html">Python&#8217;s unittest</a>).  It has most of our complaints handled out of the box.  It&#8217;s very well documented, considers a lot of aspects of testing, supports fixtures, a built-in client, etc.  It&#8217;s a well thought out framework to build tests on.</p>
<p>We&#8217;re being more vigilant about requiring tests this time around, but they also aren&#8217;t as frustrating to write.  When you write them they actually work and they stay working.  Most of what you want is built in already.  For example, I wrote the password reset form we needed on AMO in Django.  With CakePHP and SimpleTest I&#8217;d have no idea how to test that the email was actually working.  It&#8217;s apparently possible <a href="http://www.curioussymbols.com/simplemail/">with a SimpleTest add-on</a> and enough code that I have to scroll in my browser.  With Django&#8217;s test suite the actual code was 5 lines, 3 of which were assertions:</p>
<pre><code class="python">
    def test_request_success(self):
        self.client.post('/en-US/firefox/users/pwreset',
                        {'email': self.user.email})

        eq_(len(mail.outbox), 1)
        assert mail.outbox[0].subject.find('Password reset') == 0
        assert mail.outbox[0].body.find('pwreset/%s' % self.uidb36) > 0
</code></pre>
<p>With the power of the new test suite we&#8217;re once again writing and maintaining our unit tests &#8211; currently at around 390 tests and increasing steadily.  Plenty of people have written about why unit tests are important so I won&#8217;t belabor the point, but I will mention that it&#8217;s a great feeling to be able to commit something and be confident it hasn&#8217;t affected other parts of the site.  It&#8217;s almost as good of a feeling when you write your code and a completely different test fails pointing out a case that you didn&#8217;t even consider but one that would soak up developer time trying to debug down the road.  </p>
<p>Building on a foundation that takes testing seriously is great.</p>
]]></content:encoded>
			<wfw:commentRss>http://micropipes.com/blog/2010/05/03/addons-mozilla-org-%e2%99%a5s-unit-tests-again/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Continuous Integration comes to AMO</title>
		<link>http://micropipes.com/blog/2010/04/07/continuous-integration-comes-to-amo/</link>
		<comments>http://micropipes.com/blog/2010/04/07/continuous-integration-comes-to-amo/#comments</comments>
		<pubDate>Wed, 07 Apr 2010 14:54:13 +0000</pubDate>
		<dc:creator>Wil Clouser</dc:creator>
				<category><![CDATA[Mozilla]]></category>
		<category><![CDATA[AMO]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[statistics]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://micropipes.com/blog/?p=139</guid>
		<description><![CDATA[It&#8217;s time to hail another milestone for AMO in our epic push for improvements in 2010.  This time I&#8217;m happy to announce our Hudson continuous integration server which has been humming along for a few months.

Hudson Integration Screenshot.  Click to enlarge.
AMO is the first Mozilla Webdev site to use continuous integration, and it&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s time to hail another milestone for <a href="https://addons.mozilla.org/">AMO</a> in our <a href="http://micropipes.com/blog/2009/11/17/amo-development-changes-in-2010/">epic push for improvements in 2010</a>.  This time I&#8217;m happy to announce our <a href="https://hudson.mozilla.org/job/preview.addons.mozilla.org/">Hudson continuous integration server</a> which has been humming along for a few months.</p>
<p><a href="http://micropipes.com/blog/wp-content/img/hudson_screenshot.png"><img src="http://micropipes.com/blog/wp-content/img/hudson_screenshot_small.png" title="Hudson Summary Screenshot" style="border:1px solid #000; padding:10px;" /></a></p>
<caption>Hudson Integration Screenshot.  Click to enlarge.</caption>
<p>AMO is the first Mozilla Webdev site to use continuous integration, and it&#8217;s been a long time coming.  With the way it&#8217;s currently configured we&#8217;ve got <a href="https://hudson.mozilla.org/job/preview.addons.mozilla.org/512/cobertura/?">code coverage trending</a>, <a href="https://hudson.mozilla.org/job/preview.addons.mozilla.org/512/testReport/?">unit test trending</a>, <a href="https://hudson.mozilla.org/job/preview.addons.mozilla.org/512/violations/?">code quality trending</a>, as well as detailed reports for all the above for every single check in.</p>
<p>If anything fails or oversteps a threshold our IRC bot complains and we can get it fixed up quickly.  It&#8217;s a boon to productivity to know that all the code being checked in is being tested automatically, plus it gives everyone a stable state to compare to.</p>
<p>Thanks to everyone that helped get Hudson going, from the <a href="http://blog.hudson-ci.org/">people that write it</a>, to <a href="http://blog.mozilla.com/it/">the IT team that keeps it alive</a>, to <a href="http://blog.mozilla.com/webdev/">the webdev team</a> that helped work out the kinks.</p>
]]></content:encoded>
			<wfw:commentRss>http://micropipes.com/blog/2010/04/07/continuous-integration-comes-to-amo/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>addons.mozilla.org Celebrates 1000 (passing) Unit Tests</title>
		<link>http://micropipes.com/blog/2009/04/09/addonsmozillaorg-celebrates-1000-passing-unit-tests/</link>
		<comments>http://micropipes.com/blog/2009/04/09/addonsmozillaorg-celebrates-1000-passing-unit-tests/#comments</comments>
		<pubDate>Thu, 09 Apr 2009 23:16:35 +0000</pubDate>
		<dc:creator>Wil Clouser</dc:creator>
				<category><![CDATA[Mozilla]]></category>
		<category><![CDATA[AMO]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://micropipes.com/blog/?p=79</guid>
		<description><![CDATA[We started writing unit tests for AMO a few years ago with the best of intentions.  As the tests grew we started running into memory/timeout problems that prevented us from running the tests.  Other priorities took over and since we couldn&#8217;t run the tests we quit writing them.  The tests got put [...]]]></description>
			<content:encoded><![CDATA[<p>We started writing unit tests for <a href="https://addons.mozilla.org/"><abbr title="addons.mozilla.org">AMO</abbr></a> a few years ago with the best of intentions.  As the tests grew we started running into memory/timeout problems that prevented us from running the tests.  Other priorities took over and since we couldn&#8217;t run the tests we quit writing them.  The tests got put on the back burner, became stale, and we&#8217;re for the most part forgotten (an all too familiar story for most developers).</p>
<p>Over the past few months we&#8217;ve been turning that around.  While it&#8217;s certainly a team effort, it&#8217;s not stretching the truth to say that <a href="http://blog.jeffbalogh.org/">Jeff Balogh</a> has been the driving force behind making sure our framework can scale and getting our old tests running again.  Thanks to his tireless efforts our latest numbers show over <strong>1200 unit tests</strong>, 1065 of which are passing.</p>
<p>In an effort to prevent them from being forgotten again he also <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=479905">created an IRC bot named bosley</a> who tracks the tests and reminds people when they fail.  Expect to see bosley in <a href="irc://irc.mozilla.org/#amo">#amo</a> soon.</p>
<p>The number of tests and the continuous monitoring of them is a huge milestone for AMO and Mozilla WebDev.</p>
]]></content:encoded>
			<wfw:commentRss>http://micropipes.com/blog/2009/04/09/addonsmozillaorg-celebrates-1000-passing-unit-tests/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>
