<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="/stylesheets/rss.css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>Wood for the Trees: ActiveTest: Examination, Introduction: A Mistake and How To Fix It</title>
    <link>http://www.mathewabonyi.com/articles/2006/12/31/activetest-examination-introduction-a-mistake-and-how-to-fix-it</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>struggling to dig life</description>
    <item>
      <title>ActiveTest: Examination, Introduction: A Mistake and How To Fix It</title>
      <description>&lt;p style="text-align:justify;"&gt;In trying to bring ActiveTest to a state resembling my &lt;a href="http://www.mathewabonyi.com/articles/2006/11/18/first-release-activetest-rails-style-testing/"&gt;original article about ActiveTest&lt;/a&gt;, I realised that &amp;#8230; it&amp;#8217;s a piece of crap. It just isn&amp;#8217;t the kind of code which many but myself would find useful and now even I don&amp;#8217;t find it that helpful anymore. A total cowpat of a project, sadly.&lt;/p&gt;


	&lt;p style="text-align:justify;"&gt;To help both myself and the community, I will be analysing my mistake in full and mercilessly revealing my thinking process, development and design along the way. Because it may get a little&amp;#8230; lengthy, I&amp;#8217;ll break it down into a number of articles. The last article will be dedicated entirely to making Active Test useful (which itself is three parts: salvaging useful ideas, redesigning weak areas, and changing purpose).&lt;/p&gt;


	&lt;h4&gt;Obituary to Active Test 0.1.0 Beta&lt;/h4&gt;


	&lt;p style="text-align:justify;"&gt;In its death-throes, the Active Test Plugin can still be useful: as an example of what &lt;em&gt;not&lt;/em&gt; to do. Before I start laying into my sad miscarriage of an idea, I&amp;#8217;ll outline useful ideas which came out of it:&lt;/p&gt;


	&lt;ul&gt;
	&lt;li&gt;Finding a way to extend &lt;code&gt;Test::Unit&lt;/code&gt; which is safe and allows inheritance&lt;/li&gt;
		&lt;li&gt;Learning different ways of metaprogramming (especially ways to wrap &lt;code&gt;define_method&lt;/code&gt;)&lt;/li&gt;
		&lt;li&gt;Extracting a more granular set of things to test in an application&lt;/li&gt;
		&lt;li&gt;Learning techniques for self-testing a test library&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p style="text-align:justify;"&gt;As with many mistakes, more than half of it is about learning rather than providing something useful. That&amp;#8217;s kind of the point, I guess! I didn&amp;#8217;t receive a single support e-mail or comment that it has helped anyone. Then I began to realise what I was doing was wrong and had managed to air my dirty laundry in the process.&lt;/p&gt;


	&lt;h4&gt;An overview of the mistakes&lt;/h4&gt;


	&lt;p style="text-align:justify;"&gt;With that small obituary to ActiveTest in its current incarnation, let&amp;#8217;s look at the problems in the order in which I&amp;#8217;ll be discussing them:&lt;/p&gt;


	&lt;ul&gt;
	&lt;li&gt;Removing test case transparency (an advantage of Test::Unit)&lt;/li&gt;
		&lt;li&gt;Extracting and abstracting without a real-world need or basis&lt;sup&gt;&lt;a href="#fn1"&gt;1&lt;/a&gt;&lt;/sup&gt;&lt;/li&gt;
		&lt;li&gt;Excessive metaprogramming, which introduces ambiguity into tests (&lt;b&gt;the cardinal sin&lt;/b&gt;)&lt;/li&gt;
		&lt;li&gt;Code bloat, plain and simple&lt;/li&gt;
	&lt;/ul&gt;


	&lt;h4&gt;The Idea: the original test case&lt;/h4&gt;


	&lt;p style="text-align:justify;"&gt;I first came up with ActiveTest when I looked at this test case (from an old revision of one of my projects):&lt;/p&gt;


&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_ruby "&gt;  &lt;span class="keyword"&gt;def &lt;/span&gt;&lt;span class="method"&gt;test_should_index_items&lt;/span&gt;
     &lt;span class="ident"&gt;assert_get_success&lt;/span&gt; &lt;span class="symbol"&gt;:index&lt;/span&gt;
  &lt;span class="keyword"&gt;end&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

	&lt;p style="text-align:justify;"&gt;At first glance, this looks almost identical to what ActiveTest currently does. I have a case where I want to ensure that a typical &lt;span class="caps"&gt;GET&lt;/span&gt; request receives a &lt;span class="caps"&gt;HTTP 200&lt;/span&gt; response. I extrapolated &lt;span class="caps"&gt;HTTP 200&lt;/span&gt; to &lt;span class="caps"&gt;HTTP GET&lt;/span&gt; into a request-response &amp;#8216;success&amp;#8217; condition. The method was given a parameter (an action to call) that was passed to &lt;code&gt;get&lt;/code&gt; and &lt;code&gt;assert_template&lt;/code&gt;. All perfectly fine, a little &lt;span class="caps"&gt;DRY&lt;/span&gt;, but not unreadable. However, this test case and a bunch of others exactly like it formed almost the entire basis of my initial version of Active Test.&lt;/p&gt;


	&lt;p style="text-align:justify;"&gt;&lt;strong&gt;Coming Up Next: My First Mistake&amp;#8230;&lt;/strong&gt;&lt;/p&gt;


	&lt;h4&gt;Footnotes&lt;/h4&gt;


	&lt;p id="fn1"&gt;&lt;sup&gt;1&lt;/sup&gt; For a milder case of this, called premature extraction, see &lt;a href="http://www.therailsway.com/2006/11/15/tracks-part-1"&gt;this article&lt;/a&gt;&lt;/p&gt;</description>
      <pubDate>Sun, 31 Dec 2006 17:21:17 -0600</pubDate>
      <guid isPermaLink="false">urn:uuid:1d0521b4-6a4b-4064-8e4a-ba1621315aab</guid>
      <author>Mathew Abonyi</author>
      <link>http://www.mathewabonyi.com/articles/2006/12/31/activetest-examination-introduction-a-mistake-and-how-to-fix-it</link>
      <category>Discoveries</category>
      <category>Ruby</category>
      <category>Rails</category>
      <category>Plugins</category>
      <trackback:ping>http://www.mathewabonyi.com/articles/trackback/34</trackback:ping>
    </item>
  </channel>
</rss>
