<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.2" -->
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
	<title>Comments on: Testing in Rails: Way More Trouble Than Flossing</title>
	<link>http://www.thirdbit.net/articles/2007/06/27/testing-in-rails-way-more-trouble-than-flossing/</link>
	<description>Reqs. Code. Docs. Done.</description>
	<pubDate>Fri, 03 Sep 2010 08:02:31 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.2</generator>

	<item>
		<title>By: InfoQ: Rails BDD with Macros, I18n... So Remarkable</title>
		<link>http://www.thirdbit.net/articles/2007/06/27/testing-in-rails-way-more-trouble-than-flossing/#comment-1186</link>
		<author>InfoQ: Rails BDD with Macros, I18n... So Remarkable</author>
		<pubDate>Mon, 04 May 2009 15:55:15 +0000</pubDate>
		<guid>http://www.thirdbit.net/articles/2007/06/27/testing-in-rails-way-more-trouble-than-flossing/#comment-1186</guid>
		<description>&lt;!--%kramer-ref-pre%--&gt;[...] RSpec, Shoulda or Cucumber. You can also write your own custom RSpec matchers.  It can become a nightmare to make the right decisions and find the right tool. Remarkable tries to unify the syntax and adds [...]&lt;!--%kramer-ref-post%--&gt;</description>
		<content:encoded><![CDATA[<p><a href="http://dev.wp-plugins.org/wiki/Kramer"><img src="http://www.thirdbit.net/wp-content/plugins/kramer/kramer.php?kramer=gif-icon" class="technorati-balloon" alt="Kramer auto Pingback" style="border:0;" /></a>[&#8230;] RSpec, Shoulda or Cucumber. You can also write your own custom RSpec matchers.  It can become a nightmare to make the right decisions and find the right tool. Remarkable tries to unify the syntax and adds [&#8230;]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: bytesized</title>
		<link>http://www.thirdbit.net/articles/2007/06/27/testing-in-rails-way-more-trouble-than-flossing/#comment-1145</link>
		<author>bytesized</author>
		<pubDate>Fri, 27 Jun 2008 09:20:57 +0000</pubDate>
		<guid>http://www.thirdbit.net/articles/2007/06/27/testing-in-rails-way-more-trouble-than-flossing/#comment-1145</guid>
		<description>&lt;!--%kramer-ref-pre%--&gt;[...] Aug 3rd, 2007  The moral of this story is that every night as you floss your teeth, you should thank your lucky stars that something so good for you is also so easy to do. I know I will. &#8212; Testing in Rails: Way More Trouble Than Flossing [...]&lt;!--%kramer-ref-post%--&gt;</description>
		<content:encoded><![CDATA[<p><a href="http://dev.wp-plugins.org/wiki/Kramer"><img src="http://www.thirdbit.net/wp-content/plugins/kramer/kramer.php?kramer=gif-icon" class="technorati-balloon" alt="Kramer auto Pingback" style="border:0;" /></a>[&#8230;] Aug 3rd, 2007  The moral of this story is that every night as you floss your teeth, you should thank your lucky stars that something so good for you is also so easy to do. I know I will. &mdash; Testing in Rails: Way More Trouble Than Flossing [&#8230;]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Database Constraints, Stereotypes Rails, Culture, Talmud, Gender, MINASWAN, Religion. But ABSOLUTELY NO BONDAGE PLAY &#124; thirdbIT</title>
		<link>http://www.thirdbit.net/articles/2007/06/27/testing-in-rails-way-more-trouble-than-flossing/#comment-1023</link>
		<author>Database Constraints, Stereotypes Rails, Culture, Talmud, Gender, MINASWAN, Religion. But ABSOLUTELY NO BONDAGE PLAY &#124; thirdbIT</author>
		<pubDate>Fri, 02 Nov 2007 20:20:20 +0000</pubDate>
		<guid>http://www.thirdbit.net/articles/2007/06/27/testing-in-rails-way-more-trouble-than-flossing/#comment-1023</guid>
		<description>[...] I trust it much more than I trust either my own code or DHH&#8217;s. Database constraints are easy to use and good for you, just like flossing. And that appears to be the majority [...]</description>
		<content:encoded><![CDATA[<p>[&#8230;] I trust it much more than I trust either my own code or DHH&#8217;s. Database constraints are easy to use and good for you, just like flossing. And that appears to be the majority [&#8230;]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ryan</title>
		<link>http://www.thirdbit.net/articles/2007/06/27/testing-in-rails-way-more-trouble-than-flossing/#comment-532</link>
		<author>ryan</author>
		<pubDate>Mon, 06 Aug 2007 13:24:23 +0000</pubDate>
		<guid>http://www.thirdbit.net/articles/2007/06/27/testing-in-rails-way-more-trouble-than-flossing/#comment-532</guid>
		<description>Testing. Is. Not. Easy. And that's the truth. I, too, have moments when I'm questioning TDD. In fact, lately, I've been doing some things differently.

Some argue that it's best to test while you work, and some argue it's best to write the test before the method. I kind of disagree with both. For me, testing is an entirely different mindset than writing traditional Rails code. I mean, it's all Ruby, but it's different.

I have to be in a "test mode" to write solid tests, even if that means doing it later on in the project. I'm not particularly good at switching back and forth, so I'll develop a reasonable "chunk" of functionality, and then go back and write a series of tests for that chunk, later.

By separating those two, testing almost becomes addicting in some ways. I love seeing 0 failures, 0 errors, but you're absolutely right, it's often not as easy as it seems. I'm still in Test::Unit, which is fine for me (right now). I hear there are better libraries and ways to test, but this is just fine so far.

Good luck with it...</description>
		<content:encoded><![CDATA[<p>Testing. Is. Not. Easy. And that&#8217;s the truth. I, too, have moments when I&#8217;m questioning TDD. In fact, lately, I&#8217;ve been doing some things differently.</p>
<p>Some argue that it&#8217;s best to test while you work, and some argue it&#8217;s best to write the test before the method. I kind of disagree with both. For me, testing is an entirely different mindset than writing traditional Rails code. I mean, it&#8217;s all Ruby, but it&#8217;s different.</p>
<p>I have to be in a &#8220;test mode&#8221; to write solid tests, even if that means doing it later on in the project. I&#8217;m not particularly good at switching back and forth, so I&#8217;ll develop a reasonable &#8220;chunk&#8221; of functionality, and then go back and write a series of tests for that chunk, later.</p>
<p>By separating those two, testing almost becomes addicting in some ways. I love seeing 0 failures, 0 errors, but you&#8217;re absolutely right, it&#8217;s often not as easy as it seems. I&#8217;m still in Test::Unit, which is fine for me (right now). I hear there are better libraries and ways to test, but this is just fine so far.</p>
<p>Good luck with it&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Testing in Rails: Way More Trouble Than Flossing</title>
		<link>http://www.thirdbit.net/articles/2007/06/27/testing-in-rails-way-more-trouble-than-flossing/#comment-516</link>
		<author>Testing in Rails: Way More Trouble Than Flossing</author>
		<pubDate>Fri, 03 Aug 2007 21:26:40 +0000</pubDate>
		<guid>http://www.thirdbit.net/articles/2007/06/27/testing-in-rails-way-more-trouble-than-flossing/#comment-516</guid>
		<description>&lt;!--%kramer-ref-pre%--&gt;[...] gst via thirdbit.net Submitted: Aug 03 / 17:26        Testing in Rails: Way More Trouble Than Flossing  So the other day Max and I had a joint interview for a Rails job, and the hiring manager obviously [...]&lt;!--%kramer-ref-post%--&gt;</description>
		<content:encoded><![CDATA[<p><a href="http://dev.wp-plugins.org/wiki/Kramer"><img src="http://www.thirdbit.net/wp-content/plugins/kramer/kramer.php?kramer=gif-icon" class="technorati-balloon" alt="Kramer auto Pingback" style="border:0;" /></a>[&#8230;] gst via thirdbit.net Submitted: Aug 03 / 17:26        Testing in Rails: Way More Trouble Than Flossing  So the other day Max and I had a joint interview for a Rails job, and the hiring manager obviously [&#8230;]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: max</title>
		<link>http://www.thirdbit.net/articles/2007/06/27/testing-in-rails-way-more-trouble-than-flossing/#comment-101</link>
		<author>max</author>
		<pubDate>Sun, 01 Jul 2007 19:20:59 +0000</pubDate>
		<guid>http://www.thirdbit.net/articles/2007/06/27/testing-in-rails-way-more-trouble-than-flossing/#comment-101</guid>
		<description>&lt;p&gt;Sidu, thanks for the useful notes. My first readthrough was pretty funny, as I interpreted "CruiseControl.rb [...] takes under 30s" to mean that one must be under the age of 30 to install CruiseControl successfully.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Sidu, thanks for the useful notes. My first readthrough was pretty funny, as I interpreted &#8220;CruiseControl.rb [&#8230;] takes under 30s&#8221; to mean that one must be under the age of 30 to install CruiseControl successfully.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sidu</title>
		<link>http://www.thirdbit.net/articles/2007/06/27/testing-in-rails-way-more-trouble-than-flossing/#comment-100</link>
		<author>Sidu</author>
		<pubDate>Sun, 01 Jul 2007 19:08:59 +0000</pubDate>
		<guid>http://www.thirdbit.net/articles/2007/06/27/testing-in-rails-way-more-trouble-than-flossing/#comment-100</guid>
		<description>&lt;p&gt;I've generally found writing tests in Rails to be a more complex task than writing tests for plain Ruby code (or C# or Java) - mostly because Rails is all about the database. Usually, the focus of a test is one small piece of logic, but in Rails theres all this other stuff going on so it's easy to get distracted and find you're testing larger and larger chunks rather than a 'unit'.&lt;/p&gt;

&lt;p&gt;One thing I can add which I wish someone had told me when I'd started with TDD - you can't do TDD if you don't know where you're going. I used to spend a great deal of time trying to figure out how to test first when spiking or prototyping. If you're exploring an idea or evolving your design in code, but aren't sure what exactly you're aiming for, you cannot be expected to test first. Once you've got your design fleshed out then you go ahead and write tests for your logic.&lt;/p&gt;

&lt;p&gt;One deficiency in Rails testing is the lack of integrated support for functional tests. It helps to start building a functional test suite quite early in your application life-cycle. We usually use either &lt;a href="http://www.openqa.org/selenium/index.html" rel="nofollow"&gt;Selenium&lt;/a&gt; or &lt;a href="http://sahi.co.in/" rel="nofollow"&gt;Sahi&lt;/a&gt; which simulate user interactions with the browser to build these tests.
Funtional tests are usually run in a secondary build (because it can take quite long to run as the number of tests increase) triggered by the first build (the regular rake -t build) passing.&lt;/p&gt;

&lt;p&gt;Setting up your build in a &lt;a href="http://cruisecontrolrb.thoughtworks.com/" rel="nofollow"&gt;CruiseControl.rb&lt;/a&gt; instance (it takes under 30s) also helps streamline things a great deal.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>I&#8217;ve generally found writing tests in Rails to be a more complex task than writing tests for plain Ruby code (or C# or Java) - mostly because Rails is all about the database. Usually, the focus of a test is one small piece of logic, but in Rails theres all this other stuff going on so it&#8217;s easy to get distracted and find you&#8217;re testing larger and larger chunks rather than a &#8216;unit&#8217;.</p>
<p>One thing I can add which I wish someone had told me when I&#8217;d started with TDD - you can&#8217;t do TDD if you don&#8217;t know where you&#8217;re going. I used to spend a great deal of time trying to figure out how to test first when spiking or prototyping. If you&#8217;re exploring an idea or evolving your design in code, but aren&#8217;t sure what exactly you&#8217;re aiming for, you cannot be expected to test first. Once you&#8217;ve got your design fleshed out then you go ahead and write tests for your logic.</p>
<p>One deficiency in Rails testing is the lack of integrated support for functional tests. It helps to start building a functional test suite quite early in your application life-cycle. We usually use either <a href="http://www.openqa.org/selenium/index.html" rel="nofollow">Selenium</a> or <a href="http://sahi.co.in/" rel="nofollow">Sahi</a> which simulate user interactions with the browser to build these tests.<br />
Funtional tests are usually run in a secondary build (because it can take quite long to run as the number of tests increase) triggered by the first build (the regular rake -t build) passing.</p>
<p>Setting up your build in a <a href="http://cruisecontrolrb.thoughtworks.com/" rel="nofollow">CruiseControl.rb</a> instance (it takes under 30s) also helps streamline things a great deal.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gregory Brown</title>
		<link>http://www.thirdbit.net/articles/2007/06/27/testing-in-rails-way-more-trouble-than-flossing/#comment-39</link>
		<author>Gregory Brown</author>
		<pubDate>Thu, 28 Jun 2007 15:39:26 +0000</pubDate>
		<guid>http://www.thirdbit.net/articles/2007/06/27/testing-in-rails-way-more-trouble-than-flossing/#comment-39</guid>
		<description>&lt;p&gt;I was actually speaking in reference to other languages, especially C++.   Try writing tests in CppUnit or NUnit without poking your eyes out. :)&lt;/p&gt;

&lt;p&gt;But you're right.  Testing isn't easy, at first.  With respect to the decision making overhead, I find writing the tests first help with that.  Then you're not trying to form your specifications around blobs of code that may-or-may not be testable, and instead are writing what you expect right up front.&lt;/p&gt;

&lt;p&gt;It does take a whole lot of getting used to, but in practice, I've found that to dissolve the 'how should I be testing this' problem and move it into "how can I write testable code".   This usually means tiny methods that are easy to poke at when needed.  It does result in better code, too.&lt;/p&gt;

&lt;p&gt;The problem is, if you've got a job with a tight deadline you're trying to hit, maybe that's not the time to start learning to make TDD/BDD a common practice.  I've been in that boat before, and I find that even if you can't have a comprehensive test suite, it pays off to eventually layer testing in.&lt;/p&gt;

&lt;p&gt;The most important places?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Any bug reports you get, to avoid regressions&lt;/li&gt;
&lt;li&gt;Any business logic that can be expressed clearly in tests&lt;/li&gt;
&lt;li&gt;When you refactor code, add tests for that chunk to make sure you don't introduce new bugs.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I would have liked to layer in more advice like that into my article, but article length constraints and a pre-specified scope left me little room to talk about the "why?" part.&lt;/p&gt;

&lt;p&gt;Anyway... best of luck.  Hopefully things will get better over time, as if you're working in Ruby/Rails you really won't be comfortable without a strong appreciation for testing.   Most jobs sort of expect it, too. :-/&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>I was actually speaking in reference to other languages, especially C++.   Try writing tests in CppUnit or NUnit without poking your eyes out. <img src='http://www.thirdbit.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>But you&#8217;re right.  Testing isn&#8217;t easy, at first.  With respect to the decision making overhead, I find writing the tests first help with that.  Then you&#8217;re not trying to form your specifications around blobs of code that may-or-may not be testable, and instead are writing what you expect right up front.</p>
<p>It does take a whole lot of getting used to, but in practice, I&#8217;ve found that to dissolve the &#8216;how should I be testing this&#8217; problem and move it into &#8220;how can I write testable code&#8221;.   This usually means tiny methods that are easy to poke at when needed.  It does result in better code, too.</p>
<p>The problem is, if you&#8217;ve got a job with a tight deadline you&#8217;re trying to hit, maybe that&#8217;s not the time to start learning to make TDD/BDD a common practice.  I&#8217;ve been in that boat before, and I find that even if you can&#8217;t have a comprehensive test suite, it pays off to eventually layer testing in.</p>
<p>The most important places?</p>
<ul>
<li>Any bug reports you get, to avoid regressions</li>
<li>Any business logic that can be expressed clearly in tests</li>
<li>When you refactor code, add tests for that chunk to make sure you don&#8217;t introduce new bugs.</li>
</ul>
<p>I would have liked to layer in more advice like that into my article, but article length constraints and a pre-specified scope left me little room to talk about the &#8220;why?&#8221; part.</p>
<p>Anyway&#8230; best of luck.  Hopefully things will get better over time, as if you&#8217;re working in Ruby/Rails you really won&#8217;t be comfortable without a strong appreciation for testing.   Most jobs sort of expect it, too. :-/</p>
]]></content:encoded>
	</item>
</channel>
</rss>
