<?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>The Vose Way: Why Do Unit Tests Exist?</title>
    <link>http://www.chuckvose.com/articles/2006/04/20/why-do-unit-tests-exist</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>A Blog about Butter, Cheese, and Ruby on Rails</description>
    <item>
      <title>Why Do Unit Tests Exist?</title>
      <description>&lt;p&gt;Holy crap I finally figured out why unit tests exist! To give me something to think about in the shower. Yep, simple as that.&lt;/p&gt;


	&lt;p&gt;No, wait, there are two really good uses off the top of my head: packaging and testing filesystem crap.&lt;/p&gt;


	&lt;p&gt;The first use is if you&amp;#8217;re exporting a plugin for later use (or for general distribution). In this scenario there&amp;#8217;s a fairly good chance that the user importing your plugin has messed up their install or is using a database that isn&amp;#8217;t the same version or even the same type as the one you&amp;#8217;re using.&lt;/p&gt;


	&lt;p&gt;In either case if you have unit tests and none of them fail then you know that the database probably isn&amp;#8217;t at fault.&lt;/p&gt;


	&lt;p&gt;The second use is for filesystem crap. I can still count the number of times I&amp;#8217;ve messed up the permissions on a folder only to find it after a half hour of debugging. This should never happen and there are wonderful tools to prevent it. `ri File` and `ri FileUtils` should get you started if you&amp;#8217;re curious.&lt;/p&gt;


	&lt;p&gt;Specifically I&amp;#8217;ve been working on a photo upload admin because I don&amp;#8217;t understand file_column. In this I occasionally have to make a directory (okay, every time I upload something that isn&amp;#8217;t a graphic) and it would be really nice to know that when I post it onto our production server that it&amp;#8217;ll work when I release it into the wild.&lt;/p&gt;


	&lt;p&gt;Under this column is a wonderful addition to test_helper to check that things are correctly set in other places. Since rake is seperate from the dispatchers it could check their permissions, check the permissions of the public and log folders, and a myriad of other wonderful tests that could help newbies get on their way.&lt;/p&gt;


	&lt;p&gt;Rake is already pretty good at this but it serves as an excellent example of one use for unit testing.&lt;/p&gt;</description>
      <pubDate>Thu, 20 Apr 2006 14:39:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:00413d6b-6d4e-4689-b5ea-670aa1b4a648</guid>
      <author>vosechu@create-on.com (Chuck Vose)</author>
      <link>http://www.chuckvose.com/articles/2006/04/20/why-do-unit-tests-exist</link>
      <category>Rails</category>
      <category>Programming</category>
      <trackback:ping>http://www.chuckvose.com/articles/trackback/3</trackback:ping>
    </item>
  </channel>
</rss>
