<?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: Too many mock objects == ruby refactoring death</title>
	<atom:link href="http://www.moseshohman.com/blog/2008/07/06/too-many-mock-objects-ruby-refactoring-death/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.moseshohman.com/blog/2008/07/06/too-many-mock-objects-ruby-refactoring-death/</link>
	<description>software development, informatics, etc.</description>
	<lastBuildDate>Tue, 23 Aug 2011 22:57:24 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: Andho</title>
		<link>http://www.moseshohman.com/blog/2008/07/06/too-many-mock-objects-ruby-refactoring-death/comment-page-1/#comment-2512</link>
		<dc:creator>Andho</dc:creator>
		<pubDate>Tue, 23 Aug 2011 16:03:56 +0000</pubDate>
		<guid isPermaLink="false">http://www.moseshohman.com/blog/2008/07/06/too-many-mock-objects-ruby-refactoring-death/#comment-2512</guid>
		<description>&lt;p&gt;I think that an Aggregate root should not mock the objects it contains within it. If there are too many related objects to mock outside of the Aggregate, than that Class needs refactoring.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>I think that an Aggregate root should not mock the objects it contains within it. If there are too many related objects to mock outside of the Aggregate, than that Class needs refactoring.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Moses</title>
		<link>http://www.moseshohman.com/blog/2008/07/06/too-many-mock-objects-ruby-refactoring-death/comment-page-1/#comment-2388</link>
		<dc:creator>Moses</dc:creator>
		<pubDate>Sat, 14 Feb 2009 02:32:35 +0000</pubDate>
		<guid isPermaLink="false">http://www.moseshohman.com/blog/2008/07/06/too-many-mock-objects-ruby-refactoring-death/#comment-2388</guid>
		<description>&lt;p&gt;Test granularity: definitely not too coarse : )&lt;/p&gt;

&lt;p&gt;When we first started testing, we were bitten by the &quot;add a fixture and a bunch of random tests break&quot; phenomenon a few times. That was one of our motivations to move heavily into using mock-based testing. After mock-based testing bit us also, we eventually converged on the following approach to test data: use fixtures for things that are really basic and fundamental, and therefore won&#039;t need to be added to often; use the ObjectMother pattern (which goes by many other names, basically a test data factory) for one-off objects with specific states needed by your tests; use mocks when test data setup is just too arduous, or if needed for performance or some kind of external dependency.&lt;/p&gt;

&lt;p&gt;Thanks for your comment!&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Test granularity: definitely not too coarse : )</p>

<p>When we first started testing, we were bitten by the &#8220;add a fixture and a bunch of random tests break&#8221; phenomenon a few times. That was one of our motivations to move heavily into using mock-based testing. After mock-based testing bit us also, we eventually converged on the following approach to test data: use fixtures for things that are really basic and fundamental, and therefore won&#8217;t need to be added to often; use the ObjectMother pattern (which goes by many other names, basically a test data factory) for one-off objects with specific states needed by your tests; use mocks when test data setup is just too arduous, or if needed for performance or some kind of external dependency.</p>

<p>Thanks for your comment!</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Wolfram Arnold</title>
		<link>http://www.moseshohman.com/blog/2008/07/06/too-many-mock-objects-ruby-refactoring-death/comment-page-1/#comment-2385</link>
		<dc:creator>Wolfram Arnold</dc:creator>
		<pubDate>Sat, 14 Feb 2009 00:43:17 +0000</pubDate>
		<guid isPermaLink="false">http://www.moseshohman.com/blog/2008/07/06/too-many-mock-objects-ruby-refactoring-death/#comment-2385</guid>
		<description>&lt;p&gt;Hehe, it&#039;s a long running debate.  Mocks vs. fixtures.  Rspec brought many advantages that I like, such as being able to test views and helpers and controllers all independently of each other.  Oftentimes with the right granularity you can make those tests pretty lean and mean.&lt;/p&gt;

&lt;p&gt;Having said this, mocks are no end-all be-all as some of the fervent proponents have you believe.  Mocking association proxies are a pain, for example.  I&#039;ve not yet heard a good answer to this.&lt;/p&gt;

&lt;p&gt;Some projects out there are trying to centralize the mocks, these may be worth a look.&lt;/p&gt;

&lt;p&gt;On a wider perspective, though, I&#039;ve observed a very similar problem to what you&#039;re describing--you make one implementation or API change--and all hell breaks loose with your tests, even in a fixtures-based test environment, and this typically happened when new fixtures were added to add more variety to the demo data, so as to model a new case.  The upshot conclusion from this for me has always been that data and tests were too tightly coupled.  So, not knowing anything about your application, I wonder if your test granularity (and thus code granularity) is too coarse?&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Hehe, it&#8217;s a long running debate.  Mocks vs. fixtures.  Rspec brought many advantages that I like, such as being able to test views and helpers and controllers all independently of each other.  Oftentimes with the right granularity you can make those tests pretty lean and mean.</p>

<p>Having said this, mocks are no end-all be-all as some of the fervent proponents have you believe.  Mocking association proxies are a pain, for example.  I&#8217;ve not yet heard a good answer to this.</p>

<p>Some projects out there are trying to centralize the mocks, these may be worth a look.</p>

<p>On a wider perspective, though, I&#8217;ve observed a very similar problem to what you&#8217;re describing&#8211;you make one implementation or API change&#8211;and all hell breaks loose with your tests, even in a fixtures-based test environment, and this typically happened when new fixtures were added to add more variety to the demo data, so as to model a new case.  The upshot conclusion from this for me has always been that data and tests were too tightly coupled.  So, not knowing anything about your application, I wonder if your test granularity (and thus code granularity) is too coarse?</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Kevin Olbrich</title>
		<link>http://www.moseshohman.com/blog/2008/07/06/too-many-mock-objects-ruby-refactoring-death/comment-page-1/#comment-2375</link>
		<dc:creator>Kevin Olbrich</dc:creator>
		<pubDate>Thu, 13 Nov 2008 21:17:57 +0000</pubDate>
		<guid isPermaLink="false">http://www.moseshohman.com/blog/2008/07/06/too-many-mock-objects-ruby-refactoring-death/#comment-2375</guid>
		<description>&lt;p&gt;The most recent version of RSpec now supports &#039;stub_model&#039;s.  These use real objects that created at the time of use and cannot be saved to the database.  They have the advantage of allowing you to stub out attributes and still be able to call actual methods on the object.  This way you end up only stubbing the data and not the behavior associated with an object.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>The most recent version of RSpec now supports &#8216;stub_model&#8217;s.  These use real objects that created at the time of use and cannot be saved to the database.  They have the advantage of allowing you to stub out attributes and still be able to call actual methods on the object.  This way you end up only stubbing the data and not the behavior associated with an object.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Steve</title>
		<link>http://www.moseshohman.com/blog/2008/07/06/too-many-mock-objects-ruby-refactoring-death/comment-page-1/#comment-2366</link>
		<dc:creator>Steve</dc:creator>
		<pubDate>Tue, 05 Aug 2008 14:58:49 +0000</pubDate>
		<guid isPermaLink="false">http://www.moseshohman.com/blog/2008/07/06/too-many-mock-objects-ruby-refactoring-death/#comment-2366</guid>
		<description>&lt;p&gt;I totally agree with you. Mock objects have always seemed super awkward to me. I think that when you test your application, it should mimic how it&#039;s going to behave in the real world as much as possible. Otherwise, you&#039;re not really testing it fully. And I think in-memory databases are the way to go. If you use an ORM (though I haven&#039;t used one that I loved), then it should be seamless.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>I totally agree with you. Mock objects have always seemed super awkward to me. I think that when you test your application, it should mimic how it&#8217;s going to behave in the real world as much as possible. Otherwise, you&#8217;re not really testing it fully. And I think in-memory databases are the way to go. If you use an ORM (though I haven&#8217;t used one that I loved), then it should be seamless.</p>]]></content:encoded>
	</item>
</channel>
</rss>

