<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Thoughts On TDD (A Case Study With Ruby And RSpec)</title>
	<atom:link href="http://www.skorks.com/2010/01/thoughts-on-tdd-a-case-study-with-ruby-and-rspec/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.skorks.com/2010/01/thoughts-on-tdd-a-case-study-with-ruby-and-rspec/</link>
	<description>For the betterment of the software craft...</description>
	<lastBuildDate>Mon, 06 Sep 2010 12:59:05 +1000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Alan Skorkin</title>
		<link>http://www.skorks.com/2010/01/thoughts-on-tdd-a-case-study-with-ruby-and-rspec/comment-page-1/#comment-3602</link>
		<dc:creator>Alan Skorkin</dc:creator>
		<pubDate>Sun, 21 Feb 2010 23:23:40 +0000</pubDate>
		<guid isPermaLink="false">http://www.skorks.com/?p=1279#comment-3602</guid>
		<description>Hi Petyo,

I think I am of a similar mindset at the moment, i.e. mock and stub all you like in unit tests, but integration tests are a different story. That is to say, unit tests are interaction tests while integration tests are functionality tests. 

And yeah definitely would be good to have more rspec stuff to read around the web. Hmm, maybe i&#039;ll write some, I am no expert, but somebody gotta do it :).</description>
		<content:encoded><![CDATA[<p>Hi Petyo,</p>
<p>I think I am of a similar mindset at the moment, i.e. mock and stub all you like in unit tests, but integration tests are a different story. That is to say, unit tests are interaction tests while integration tests are functionality tests. </p>
<p>And yeah definitely would be good to have more rspec stuff to read around the web. Hmm, maybe i&#8217;ll write some, I am no expert, but somebody gotta do it :).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Petyo Ivanov</title>
		<link>http://www.skorks.com/2010/01/thoughts-on-tdd-a-case-study-with-ruby-and-rspec/comment-page-1/#comment-3598</link>
		<dc:creator>Petyo Ivanov</dc:creator>
		<pubDate>Sun, 21 Feb 2010 18:10:23 +0000</pubDate>
		<guid isPermaLink="false">http://www.skorks.com/?p=1279#comment-3598</guid>
		<description>Nice article, bothered by the similar thoughts these days. Constantly re-reading the rspec book, and lurking David Chelimsky writings to figure stuff out. 

My two cents: There should be a clear distinction between white box and black box tests. I prefer to think of them as integration and and unit ones (would rather not argue over the names though). 

Integration tests set a goal. Passing an integration test means you have completed certain functionality. Unless you really have to, you are not supposed to mock there. They are the ones revealing intention, the ones describing the purpose of the task. 

Unit tests (or specs) are more like a design tool, supposed to help you doing it right.  Feel free to mock and stub there, especially when you deal with interaction. You will probably cut yourself at first (at least I did, the first hundred times or so) doing it, it gets better over time. 

Of course, nothing can save you in case you don&#039;t know what you&#039;re trying to do (mocks and stubs may confuse you even more). Spikes and code tend to be thrown away can help here. 

Refactoring may break such kind of design oriented tests - but it is ok as long as the integration tests pass. By the way if you&#039;re cool, you will do refactoring test-first.</description>
		<content:encoded><![CDATA[<p>Nice article, bothered by the similar thoughts these days. Constantly re-reading the rspec book, and lurking David Chelimsky writings to figure stuff out. </p>
<p>My two cents: There should be a clear distinction between white box and black box tests. I prefer to think of them as integration and and unit ones (would rather not argue over the names though). </p>
<p>Integration tests set a goal. Passing an integration test means you have completed certain functionality. Unless you really have to, you are not supposed to mock there. They are the ones revealing intention, the ones describing the purpose of the task. </p>
<p>Unit tests (or specs) are more like a design tool, supposed to help you doing it right.  Feel free to mock and stub there, especially when you deal with interaction. You will probably cut yourself at first (at least I did, the first hundred times or so) doing it, it gets better over time. </p>
<p>Of course, nothing can save you in case you don&#8217;t know what you&#8217;re trying to do (mocks and stubs may confuse you even more). Spikes and code tend to be thrown away can help here. </p>
<p>Refactoring may break such kind of design oriented tests &#8211; but it is ok as long as the integration tests pass. By the way if you&#8217;re cool, you will do refactoring test-first.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alan Skorkin</title>
		<link>http://www.skorks.com/2010/01/thoughts-on-tdd-a-case-study-with-ruby-and-rspec/comment-page-1/#comment-3484</link>
		<dc:creator>Alan Skorkin</dc:creator>
		<pubDate>Sat, 06 Feb 2010 02:04:24 +0000</pubDate>
		<guid isPermaLink="false">http://www.skorks.com/?p=1279#comment-3484</guid>
		<description>You&#039;ve picked up on my main point in that however you choose to write your tests as long as your way forces you to think about your implementation upfront and really try to understand what you&#039;re doing your already a step ahead. 

You said it yourself &#039;the understanding drives the implementation&#039;,  not the test. This is I think the difference between test driven and test first. My understanding is that strong TDD proponents argue that the tests can drive the implementation without you needed a deep understanding of what you&#039;re trying to do. This is where it falls over for me.</description>
		<content:encoded><![CDATA[<p>You&#8217;ve picked up on my main point in that however you choose to write your tests as long as your way forces you to think about your implementation upfront and really try to understand what you&#8217;re doing your already a step ahead. </p>
<p>You said it yourself &#8216;the understanding drives the implementation&#8217;,  not the test. This is I think the difference between test driven and test first. My understanding is that strong TDD proponents argue that the tests can drive the implementation without you needed a deep understanding of what you&#8217;re trying to do. This is where it falls over for me.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alan Skorkin</title>
		<link>http://www.skorks.com/2010/01/thoughts-on-tdd-a-case-study-with-ruby-and-rspec/comment-page-1/#comment-3483</link>
		<dc:creator>Alan Skorkin</dc:creator>
		<pubDate>Sat, 06 Feb 2010 01:59:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.skorks.com/?p=1279#comment-3483</guid>
		<description>I would definitely agree with that, write as many tests as you need to feel like you&#039;ve adequately covered the code. 

My point is that with interaction based testing, you don&#039;t have to write as many, since you cover the interactions there is only one or two ways the implementation can fall out. 

If you do intent based testing you&#039;re forced to write many more tests simply to insure (i.e. drive) the correctness of the implementation.</description>
		<content:encoded><![CDATA[<p>I would definitely agree with that, write as many tests as you need to feel like you&#8217;ve adequately covered the code. </p>
<p>My point is that with interaction based testing, you don&#8217;t have to write as many, since you cover the interactions there is only one or two ways the implementation can fall out. </p>
<p>If you do intent based testing you&#8217;re forced to write many more tests simply to insure (i.e. drive) the correctness of the implementation.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrew</title>
		<link>http://www.skorks.com/2010/01/thoughts-on-tdd-a-case-study-with-ruby-and-rspec/comment-page-1/#comment-3481</link>
		<dc:creator>Andrew</dc:creator>
		<pubDate>Fri, 05 Feb 2010 21:14:17 +0000</pubDate>
		<guid isPermaLink="false">http://www.skorks.com/?p=1279#comment-3481</guid>
		<description>One of the things I enjoy about TDD is that it really encourages me to think about what I want from a given method or object independently from how it would be implemented. I don&#039;t care how it matches strings to determine which is the right one to select, I just want to make sure it follows my expectations for what it should and shouldn&#039;t match. 

The process forces me to really think about what it is that I need first, and then that understanding drives implementation.

The other benefit this has is that when someone else comes along and looks at the test, the test can communicate the intent, not the implementation. I feel like using mocks so heavily makes it harder to see that intent.</description>
		<content:encoded><![CDATA[<p>One of the things I enjoy about TDD is that it really encourages me to think about what I want from a given method or object independently from how it would be implemented. I don&#8217;t care how it matches strings to determine which is the right one to select, I just want to make sure it follows my expectations for what it should and shouldn&#8217;t match. </p>
<p>The process forces me to really think about what it is that I need first, and then that understanding drives implementation.</p>
<p>The other benefit this has is that when someone else comes along and looks at the test, the test can communicate the intent, not the implementation. I feel like using mocks so heavily makes it harder to see that intent.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Allan</title>
		<link>http://www.skorks.com/2010/01/thoughts-on-tdd-a-case-study-with-ruby-and-rspec/comment-page-1/#comment-3479</link>
		<dc:creator>Allan</dc:creator>
		<pubDate>Fri, 05 Feb 2010 18:06:15 +0000</pubDate>
		<guid isPermaLink="false">http://www.skorks.com/?p=1279#comment-3479</guid>
		<description>Being able to pass the tests given is the whole point. If the tests are not exhaustive (or sensible) then, yes, you can write an implementation that does nothing but pass the tests.

I&#039;d say that your interpretation of TDD is Test Defined Development no Test Driven Development :-)

For me the, ability to refactor safely with more tests outweighs the brevity of the test suite.

Allan</description>
		<content:encoded><![CDATA[<p>Being able to pass the tests given is the whole point. If the tests are not exhaustive (or sensible) then, yes, you can write an implementation that does nothing but pass the tests.</p>
<p>I&#8217;d say that your interpretation of TDD is Test Defined Development no Test Driven Development :-)</p>
<p>For me the, ability to refactor safely with more tests outweighs the brevity of the test suite.</p>
<p>Allan</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alan Skorkin</title>
		<link>http://www.skorks.com/2010/01/thoughts-on-tdd-a-case-study-with-ruby-and-rspec/comment-page-1/#comment-3474</link>
		<dc:creator>Alan Skorkin</dc:creator>
		<pubDate>Thu, 04 Feb 2010 05:10:56 +0000</pubDate>
		<guid isPermaLink="false">http://www.skorks.com/?p=1279#comment-3474</guid>
		<description>That is definitely a good argument against interaction based unit tests, however if you employ that approach how do you drive your implementation through your tests? It is test driven development after all if all you supply is input and outputs, i can very easily dummy up the functionality of the method to get the test to pass, or implement incorrectly but still fir the tests that you have. 

You will need a great many tests to ensure correct implementation this way. With the interaction based approach, you can force your implementation where you want it to go with a reasonably number of tests (1 or 2). There are points for and against either approach and like I said, I do tend to change my mind from time to time regarding which is best.</description>
		<content:encoded><![CDATA[<p>That is definitely a good argument against interaction based unit tests, however if you employ that approach how do you drive your implementation through your tests? It is test driven development after all if all you supply is input and outputs, i can very easily dummy up the functionality of the method to get the test to pass, or implement incorrectly but still fir the tests that you have. </p>
<p>You will need a great many tests to ensure correct implementation this way. With the interaction based approach, you can force your implementation where you want it to go with a reasonably number of tests (1 or 2). There are points for and against either approach and like I said, I do tend to change my mind from time to time regarding which is best.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Allan</title>
		<link>http://www.skorks.com/2010/01/thoughts-on-tdd-a-case-study-with-ruby-and-rspec/comment-page-1/#comment-3473</link>
		<dc:creator>Allan</dc:creator>
		<pubDate>Thu, 04 Feb 2010 01:43:12 +0000</pubDate>
		<guid isPermaLink="false">http://www.skorks.com/?p=1279#comment-3473</guid>
		<description>Hi, nice article, got me thinking.

I don&#039;t believe that the white box approach to TDD you describe is really a flexible approach. 

What if the developer decides that it&#039;s more efficient to slurp the whole file into memory and iterate over that, emitting a character at a time? The end result is identical but the implementation is different and the tests fail. Now how does that fit into the whole refactoring scenario where your tests ensure you haven&#039;t broken anything when making functionally neutral changes?

I think a less invasive test that supplies input and expected output would be better, rather than prescribing the implementation also. As written above, if you change your implementation, you don&#039;t know if it&#039;s correct. At least not until you also change your test to match, which kind of defeats much of the purpose of tests...

Allan</description>
		<content:encoded><![CDATA[<p>Hi, nice article, got me thinking.</p>
<p>I don&#8217;t believe that the white box approach to TDD you describe is really a flexible approach. </p>
<p>What if the developer decides that it&#8217;s more efficient to slurp the whole file into memory and iterate over that, emitting a character at a time? The end result is identical but the implementation is different and the tests fail. Now how does that fit into the whole refactoring scenario where your tests ensure you haven&#8217;t broken anything when making functionally neutral changes?</p>
<p>I think a less invasive test that supplies input and expected output would be better, rather than prescribing the implementation also. As written above, if you change your implementation, you don&#8217;t know if it&#8217;s correct. At least not until you also change your test to match, which kind of defeats much of the purpose of tests&#8230;</p>
<p>Allan</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alan Skorkin</title>
		<link>http://www.skorks.com/2010/01/thoughts-on-tdd-a-case-study-with-ruby-and-rspec/comment-page-1/#comment-3463</link>
		<dc:creator>Alan Skorkin</dc:creator>
		<pubDate>Tue, 02 Feb 2010 01:51:04 +0000</pubDate>
		<guid isPermaLink="false">http://www.skorks.com/?p=1279#comment-3463</guid>
		<description>I actually really appreciate hearing this point of view, I tend to oscillate in my thinking about testing every few years, from &quot;mocks are evil&quot; to &quot;mocks are great&quot; (and in countless other ways as well). I believe your thinking about tests constantly evolves as you learn more and depending on the project you&#039;re working in and the language you&#039;re using and even your environment you may find yourself happily doing things with your tests that you never would have considered before. 

You&#039;re right I could easily have used stringIO and not bothered with interaction testing. My current thinking is, if you&#039;re doing unit tests then I do care about the interaction and how the method does it&#039;s work, as soon as I go a level up to integration style tests, then black box is the way to go. But like I said, I do remember myself holding a different opinion at one point :).

The ultimate goal is to produce better quality, more readable and maintainable code, if the testing style you use helps you do that, then that is a good thing.</description>
		<content:encoded><![CDATA[<p>I actually really appreciate hearing this point of view, I tend to oscillate in my thinking about testing every few years, from &#8220;mocks are evil&#8221; to &#8220;mocks are great&#8221; (and in countless other ways as well). I believe your thinking about tests constantly evolves as you learn more and depending on the project you&#8217;re working in and the language you&#8217;re using and even your environment you may find yourself happily doing things with your tests that you never would have considered before. </p>
<p>You&#8217;re right I could easily have used stringIO and not bothered with interaction testing. My current thinking is, if you&#8217;re doing unit tests then I do care about the interaction and how the method does it&#8217;s work, as soon as I go a level up to integration style tests, then black box is the way to go. But like I said, I do remember myself holding a different opinion at one point :).</p>
<p>The ultimate goal is to produce better quality, more readable and maintainable code, if the testing style you use helps you do that, then that is a good thing.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Steve Conover</title>
		<link>http://www.skorks.com/2010/01/thoughts-on-tdd-a-case-study-with-ruby-and-rspec/comment-page-1/#comment-3462</link>
		<dc:creator>Steve Conover</dc:creator>
		<pubDate>Mon, 01 Feb 2010 16:01:06 +0000</pubDate>
		<guid isPermaLink="false">http://www.skorks.com/?p=1279#comment-3462</guid>
		<description>Criticizing someone&#039;s style is a bit like criticizing someone&#039;s mom.  Perhaps this is all a matter of taste and we can agree to disagree.

I write code test-first every day and honestly if the mock-oriented style above were to take over I think I would elect to stop testing.  I just don&#039;t see the point, I don&#039;t understand what it is that you think you&#039;re testing...to me you&#039;re just re-expressing the implementation one more time.  The details of your implementation are strewn about and now you just have one more binding to that particular way of doing things.

Couldn&#039;t you just really make a file, really read it, maybe pass in a StringIO or something instead of stdout and examine what it prints?  Then the assertion of postconditions can even come *after* the thing under test executes (Set up experiment.  Run.  Assert postconditions).

Every time I get a test failure from a test that&#039;s a mock/stub extravaganza I wonder, what&#039;s the point of even having this &quot;test&quot;?  Why do you care so much about the &quot;how&quot; - isn&#039;t this just pouring a cast around my code rather than adding any value?  Ideally (to me) tests read like experiments of a black box.

But maybe I&#039;m just a deeply committed state-based tester talking to a committed interaction tester.

-Steve</description>
		<content:encoded><![CDATA[<p>Criticizing someone&#8217;s style is a bit like criticizing someone&#8217;s mom.  Perhaps this is all a matter of taste and we can agree to disagree.</p>
<p>I write code test-first every day and honestly if the mock-oriented style above were to take over I think I would elect to stop testing.  I just don&#8217;t see the point, I don&#8217;t understand what it is that you think you&#8217;re testing&#8230;to me you&#8217;re just re-expressing the implementation one more time.  The details of your implementation are strewn about and now you just have one more binding to that particular way of doing things.</p>
<p>Couldn&#8217;t you just really make a file, really read it, maybe pass in a StringIO or something instead of stdout and examine what it prints?  Then the assertion of postconditions can even come *after* the thing under test executes (Set up experiment.  Run.  Assert postconditions).</p>
<p>Every time I get a test failure from a test that&#8217;s a mock/stub extravaganza I wonder, what&#8217;s the point of even having this &#8220;test&#8221;?  Why do you care so much about the &#8220;how&#8221; &#8211; isn&#8217;t this just pouring a cast around my code rather than adding any value?  Ideally (to me) tests read like experiments of a black box.</p>
<p>But maybe I&#8217;m just a deeply committed state-based tester talking to a committed interaction tester.</p>
<p>-Steve</p>
]]></content:encoded>
	</item>
</channel>
</rss>
