<?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: Behaviours in MSpec</title>
	<atom:link href="http://lostechies.com/jamesgregory/2010/01/18/behaviours-in-mspec/feed/" rel="self" type="application/rss+xml" />
	<link>http://lostechies.com/jamesgregory/2010/01/18/behaviours-in-mspec/</link>
	<description>Just another LosTechies site</description>
	<lastBuildDate>Wed, 05 Jun 2013 14:00:00 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.4.2</generator>
	<item>
		<title>By: James Gregory</title>
		<link>http://lostechies.com/jamesgregory/2010/01/18/behaviours-in-mspec/#comment-64</link>
		<dc:creator>James Gregory</dc:creator>
		<pubDate>Thu, 28 Jan 2010 09:06:51 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jagregory/archive/2010/01/18/behaviours-in-mspec.aspx#comment-64</guid>
		<description>Sorry, jumped on you a bit there. :)

Agree with everything you said. If you are using behaves_like, there&#039;s a very good chance your class is doing too much; in most cases I wouldn&#039;t encourage it&#039;s use for this exact reason.

In FNH&#039;s case, ClassMap is doing too much, but as the public API that&#039;s it&#039;s job; no matter how I slice it up underneath, ClassMap is always going to have to expose all these methods and thus always need testing. I could compose the ClassMap from various smaller classes and test those individually, but in the end I&#039;d still need to test everything on ClassMap, because that&#039;s what the public uses. So it&#039;s specs galore no matter how I slice it.

Thanks again for MSpec, keep up the good work.</description>
		<content:encoded><![CDATA[<p>Sorry, jumped on you a bit there. <img src='http://lostechies.com/jamesgregory/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Agree with everything you said. If you are using behaves_like, there&#8217;s a very good chance your class is doing too much; in most cases I wouldn&#8217;t encourage it&#8217;s use for this exact reason.</p>
<p>In FNH&#8217;s case, ClassMap is doing too much, but as the public API that&#8217;s it&#8217;s job; no matter how I slice it up underneath, ClassMap is always going to have to expose all these methods and thus always need testing. I could compose the ClassMap from various smaller classes and test those individually, but in the end I&#8217;d still need to test everything on ClassMap, because that&#8217;s what the public uses. So it&#8217;s specs galore no matter how I slice it.</p>
<p>Thanks again for MSpec, keep up the good work.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Aaron Jensen</title>
		<link>http://lostechies.com/jamesgregory/2010/01/18/behaviours-in-mspec/#comment-63</link>
		<dc:creator>Aaron Jensen</dc:creator>
		<pubDate>Thu, 28 Jan 2010 03:04:30 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jagregory/archive/2010/01/18/behaviours-in-mspec.aspx#comment-63</guid>
		<description>Hi James,

It sounds like you&#039;ve got a good use case for the feature. It also sounds like you understand the tradeoffs. That&#039;s all I was really trying to point out. The feature is still there to be used, but people should understand the downsides. I did not say never, nor would I ever ;) 

Another thing to consider when being tempted to use this feature is that maybe this behavior should be broken into something separate that is testable once. It could be an indication that your class is doing too much and it&#039;s time for composition rather than inheritance or some other refactoring. It doesn&#039;t seem like this applies to your scenario, I just wanted to point that out as well--another thing to be aware of.

I&#039;m glad you&#039;re enjoying MSpec and the behaves like feature, thanks for sharing your experiences.

</description>
		<content:encoded><![CDATA[<p>Hi James,</p>
<p>It sounds like you&#8217;ve got a good use case for the feature. It also sounds like you understand the tradeoffs. That&#8217;s all I was really trying to point out. The feature is still there to be used, but people should understand the downsides. I did not say never, nor would I ever <img src='http://lostechies.com/jamesgregory/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  </p>
<p>Another thing to consider when being tempted to use this feature is that maybe this behavior should be broken into something separate that is testable once. It could be an indication that your class is doing too much and it&#8217;s time for composition rather than inheritance or some other refactoring. It doesn&#8217;t seem like this applies to your scenario, I just wanted to point that out as well&#8211;another thing to be aware of.</p>
<p>I&#8217;m glad you&#8217;re enjoying MSpec and the behaves like feature, thanks for sharing your experiences.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: James Gregory</title>
		<link>http://lostechies.com/jamesgregory/2010/01/18/behaviours-in-mspec/#comment-62</link>
		<dc:creator>James Gregory</dc:creator>
		<pubDate>Wed, 27 Jan 2010 23:30:04 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jagregory/archive/2010/01/18/behaviours-in-mspec.aspx#comment-62</guid>
		<description>I agree that you should use with care, definitely.

As for DRY in tests, well, never is a strong word (although I don&#039;t think you actually said never, but it was implied). It&#039;s all about trade-offs. Readability over maintainability.

Lets take an example that sparked this post. Fluent NHibernate exposes a Map method on ClassMap for mapping properties, this method is also available on the following: Components, DynamicComponents, CompositeElements, Subclasses, JoinedSubclasses, Joins, and probably others that I&#039;m forgetting. I&#039;ve got a few specs that cover the particular behaviour that method exposes, those specs are then repeated for each of those classes I just listed; technically they share the same implementation, but that&#039;s an assumption that shouldn&#039;t be made in my specs. 

Assuming I&#039;ve got 5 specs for the Map method, that&#039;s 35 specs for those classes listed. If I add a new piece of functionality that is spread across the many classes like Map is, I have to go through and create another 35+ specs; if I create another class similar to ClassMap, I have to recreate those 35 specs for the new implementation. Take that experience and multiply it by the 30+ methods and properties we expose on each of our classes, and you&#039;ve got some serious spec explosion and a pending maintenance nightmare.

In that scenario I&#039;m much more willing to sacrifice a bit of readability in my specifications (and after all, it only affects the _code_, not the spec output) for the simplification of testing any additions/modifications that may be made to the interface. Without this functionality MSpec would be just as inadequate as any of the other testing frameworks, I&#039;m happy it&#039;s in there.</description>
		<content:encoded><![CDATA[<p>I agree that you should use with care, definitely.</p>
<p>As for DRY in tests, well, never is a strong word (although I don&#8217;t think you actually said never, but it was implied). It&#8217;s all about trade-offs. Readability over maintainability.</p>
<p>Lets take an example that sparked this post. Fluent NHibernate exposes a Map method on ClassMap for mapping properties, this method is also available on the following: Components, DynamicComponents, CompositeElements, Subclasses, JoinedSubclasses, Joins, and probably others that I&#8217;m forgetting. I&#8217;ve got a few specs that cover the particular behaviour that method exposes, those specs are then repeated for each of those classes I just listed; technically they share the same implementation, but that&#8217;s an assumption that shouldn&#8217;t be made in my specs. </p>
<p>Assuming I&#8217;ve got 5 specs for the Map method, that&#8217;s 35 specs for those classes listed. If I add a new piece of functionality that is spread across the many classes like Map is, I have to go through and create another 35+ specs; if I create another class similar to ClassMap, I have to recreate those 35 specs for the new implementation. Take that experience and multiply it by the 30+ methods and properties we expose on each of our classes, and you&#8217;ve got some serious spec explosion and a pending maintenance nightmare.</p>
<p>In that scenario I&#8217;m much more willing to sacrifice a bit of readability in my specifications (and after all, it only affects the _code_, not the spec output) for the simplification of testing any additions/modifications that may be made to the interface. Without this functionality MSpec would be just as inadequate as any of the other testing frameworks, I&#8217;m happy it&#8217;s in there.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Aaron Jensen</title>
		<link>http://lostechies.com/jamesgregory/2010/01/18/behaviours-in-mspec/#comment-61</link>
		<dc:creator>Aaron Jensen</dc:creator>
		<pubDate>Wed, 27 Jan 2010 23:13:13 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jagregory/archive/2010/01/18/behaviours-in-mspec.aspx#comment-61</guid>
		<description>Behaviors are actually not documented or mentioned on my blog on purpose. I figured someone would find it eventually, but I didn’t want to promote it. I actually considered removing it.

One of the biggest goals of mspec and context/spec in general is to make the tests easily scannable. Behaviors breaks this. It plays to our (being geeks) need to apply tools and methods we know without considering context.

DRY does *not* apply to tests the same way it applies to code. DRYing up your tests is local optimization at its finest. By doing it, you reduce the lines of code but you also reduce the ease of understanding and ability to scan the test files. Don’t get me wrong, some cruft still should be abstracted/hidden, but the *core* of your specs is the specifications themselves. Behaviors hide those behind another class making full understanding from the code an extremely jarring experience.

Use with care.</description>
		<content:encoded><![CDATA[<p>Behaviors are actually not documented or mentioned on my blog on purpose. I figured someone would find it eventually, but I didn’t want to promote it. I actually considered removing it.</p>
<p>One of the biggest goals of mspec and context/spec in general is to make the tests easily scannable. Behaviors breaks this. It plays to our (being geeks) need to apply tools and methods we know without considering context.</p>
<p>DRY does *not* apply to tests the same way it applies to code. DRYing up your tests is local optimization at its finest. By doing it, you reduce the lines of code but you also reduce the ease of understanding and ability to scan the test files. Don’t get me wrong, some cruft still should be abstracted/hidden, but the *core* of your specs is the specifications themselves. Behaviors hide those behind another class making full understanding from the code an extremely jarring experience.</p>
<p>Use with care.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: CraigCav</title>
		<link>http://lostechies.com/jamesgregory/2010/01/18/behaviours-in-mspec/#comment-60</link>
		<dc:creator>CraigCav</dc:creator>
		<pubDate>Wed, 27 Jan 2010 13:43:08 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jagregory/archive/2010/01/18/behaviours-in-mspec.aspx#comment-60</guid>
		<description>James,

I really like how behaviours can keep our code DRY, but I have a few reservations regarding the API - primarily that the Behaves_like field has/needs no value.

I&#039;ve written up my thoughts on my blog:
http://craigcav.wordpress.com/2010/01/27/behaviours-in-mspec/

Craig</description>
		<content:encoded><![CDATA[<p>James,</p>
<p>I really like how behaviours can keep our code DRY, but I have a few reservations regarding the API &#8211; primarily that the Behaves_like field has/needs no value.</p>
<p>I&#8217;ve written up my thoughts on my blog:<br />
<a href="http://craigcav.wordpress.com/2010/01/27/behaviours-in-mspec/" rel="nofollow">http://craigcav.wordpress.com/2010/01/27/behaviours-in-mspec/</a></p>
<p>Craig</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: James Gregory</title>
		<link>http://lostechies.com/jamesgregory/2010/01/18/behaviours-in-mspec/#comment-59</link>
		<dc:creator>James Gregory</dc:creator>
		<pubDate>Fri, 22 Jan 2010 11:04:09 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jagregory/archive/2010/01/18/behaviours-in-mspec.aspx#comment-59</guid>
		<description>@alex: That makes sense. I wouldn&#039;t really want the behaviours to be exposed in the reports, as it&#039;s just clouding the output; however, it is quite a nice touch in the R# runner. As you can (and I frequently do) use the R# runner to navigate around your specs, hiding away that certain ones are from a behaviour could easily lead to confusion.

It&#039;s a great feature, and I&#039;m glad it&#039;s there. It&#039;s potentially open for abuse, but as are most great features.</description>
		<content:encoded><![CDATA[<p>@alex: That makes sense. I wouldn&#8217;t really want the behaviours to be exposed in the reports, as it&#8217;s just clouding the output; however, it is quite a nice touch in the R# runner. As you can (and I frequently do) use the R# runner to navigate around your specs, hiding away that certain ones are from a behaviour could easily lead to confusion.</p>
<p>It&#8217;s a great feature, and I&#8217;m glad it&#8217;s there. It&#8217;s potentially open for abuse, but as are most great features.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alexander Gro&#223;</title>
		<link>http://lostechies.com/jamesgregory/2010/01/18/behaviours-in-mspec/#comment-58</link>
		<dc:creator>Alexander Gro&#223;</dc:creator>
		<pubDate>Fri, 22 Jan 2010 10:44:40 +0000</pubDate>
		<guid isPermaLink="false">/blogs/jagregory/archive/2010/01/18/behaviours-in-mspec.aspx#comment-58</guid>
		<description>James,

Referring to your tweet, that post totally makes sense! :)

Let me explain one technical detail: As you stated above the behavior specifications (VehicleThatHasBeenStartedBehaviors&#039; It fields) get injected into the respective context. From the console/TD.NET/HTML report you won&#039;t be able to tell that &quot;should have a running engine&quot; came from a behavior, these are unaware of behaviors.
The only place that is really aware of behavior specifications is the ReSharper runner that will show a sub-tree for each behavior that was injected into a context.

Alex

</description>
		<content:encoded><![CDATA[<p>James,</p>
<p>Referring to your tweet, that post totally makes sense! <img src='http://lostechies.com/jamesgregory/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Let me explain one technical detail: As you stated above the behavior specifications (VehicleThatHasBeenStartedBehaviors&#8217; It fields) get injected into the respective context. From the console/TD.NET/HTML report you won&#8217;t be able to tell that &#8220;should have a running engine&#8221; came from a behavior, these are unaware of behaviors.<br />
The only place that is really aware of behavior specifications is the ReSharper runner that will show a sub-tree for each behavior that was injected into a context.</p>
<p>Alex</p>
]]></content:encoded>
	</item>
</channel>
</rss>
