<?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/"
	xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: Find tests more easily in your Rails test.log</title>
	<atom:link href="http://bmorearty.wordpress.com/2008/06/18/find-tests-more-easily-in-your-testlog/feed/" rel="self" type="application/rss+xml" />
	<link>http://bmorearty.wordpress.com/2008/06/18/find-tests-more-easily-in-your-testlog/</link>
	<description>Brian Morearty's Blog</description>
	<lastBuildDate>Fri, 06 Nov 2009 03:28:37 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Russ Kuhn</title>
		<link>http://bmorearty.wordpress.com/2008/06/18/find-tests-more-easily-in-your-testlog/#comment-499</link>
		<dc:creator>Russ Kuhn</dc:creator>
		<pubDate>Tue, 27 Oct 2009 16:02:05 +0000</pubDate>
		<guid isPermaLink="false">http://bmorearty.wordpress.com/?p=19#comment-499</guid>
		<description>As of Rails 2.3.4, if not earlier, @method_name is not supported and should be replaced with just name, as in

Rails::logger.info &quot;\n\nStarting #{name}\n#{&#039;-&#039; * (9 + @name.length)}\n&quot;</description>
		<content:encoded><![CDATA[<p>As of Rails 2.3.4, if not earlier, @method_name is not supported and should be replaced with just name, as in</p>
<p>Rails::logger.info &#8220;\n\nStarting #{name}\n#{&#8216;-&#8217; * (9 + @name.length)}\n&#8221;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brian</title>
		<link>http://bmorearty.wordpress.com/2008/06/18/find-tests-more-easily-in-your-testlog/#comment-51</link>
		<dc:creator>Brian</dc:creator>
		<pubDate>Sun, 26 Oct 2008 13:43:53 +0000</pubDate>
		<guid isPermaLink="false">http://bmorearty.wordpress.com/?p=19#comment-51</guid>
		<description>I have this working (Rails 2.0.2, ruby 1.8.4), but it’s not DRY and there are better ways.  Fernando Blat Talks about how to add special actions before and after each test via an alias_method_chain for the run method:
 
http://www.inwebwetrust.net/post/2008/08/19/redefine-the-run-method-of-test-unit-testcase

Anyway, this is what I did before finding Fernando’s approach:

For Unit Tests, add the setup method below in each test .rb file (you can also add a teardown method to log the end of the test, but having the start logged between each test was a good enough of delimiter for me).  If you already have a setup method, of course just add the logger code line.

def setup
  RAILS_DEFAULT_LOGGER.info &quot;\n\nStarting #{@method_name}\n#{&#039;-&#039; * (9 + @method_name.length)}\n&quot;  
end

For Functional tests (because mine still use Test::Unit::TestCase), simply add the logger code line to the existing setup method.

Sorry for the previous posts and confusion.  There is a better approach to keep this DRY, but until I figure that out, this is what I’ve done, it worked, so I thought I’d share -- but I encourage you to learn the proper approach.

b</description>
		<content:encoded><![CDATA[<p>I have this working (Rails 2.0.2, ruby 1.8.4), but it’s not DRY and there are better ways.  Fernando Blat Talks about how to add special actions before and after each test via an alias_method_chain for the run method:</p>
<p><a href="http://www.inwebwetrust.net/post/2008/08/19/redefine-the-run-method-of-test-unit-testcase" rel="nofollow">http://www.inwebwetrust.net/post/2008/08/19/redefine-the-run-method-of-test-unit-testcase</a></p>
<p>Anyway, this is what I did before finding Fernando’s approach:</p>
<p>For Unit Tests, add the setup method below in each test .rb file (you can also add a teardown method to log the end of the test, but having the start logged between each test was a good enough of delimiter for me).  If you already have a setup method, of course just add the logger code line.</p>
<p>def setup<br />
  RAILS_DEFAULT_LOGGER.info &#8220;\n\nStarting #{@method_name}\n#{&#8216;-&#8217; * (9 + @method_name.length)}\n&#8221;<br />
end</p>
<p>For Functional tests (because mine still use Test::Unit::TestCase), simply add the logger code line to the existing setup method.</p>
<p>Sorry for the previous posts and confusion.  There is a better approach to keep this DRY, but until I figure that out, this is what I’ve done, it worked, so I thought I’d share &#8212; but I encourage you to learn the proper approach.</p>
<p>b</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brian</title>
		<link>http://bmorearty.wordpress.com/2008/06/18/find-tests-more-easily-in-your-testlog/#comment-50</link>
		<dc:creator>Brian</dc:creator>
		<pubDate>Sat, 25 Oct 2008 17:22:18 +0000</pubDate>
		<guid isPermaLink="false">http://bmorearty.wordpress.com/?p=19#comment-50</guid>
		<description>Ah, didn&#039;t break unit tests, but broke functional tests (I should have checked before posting).  How can this be overridden properly in test_helper.rb?  Or, should I place the method in each unit test rb file like functional tests?

b</description>
		<content:encoded><![CDATA[<p>Ah, didn&#8217;t break unit tests, but broke functional tests (I should have checked before posting).  How can this be overridden properly in test_helper.rb?  Or, should I place the method in each unit test rb file like functional tests?</p>
<p>b</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brian</title>
		<link>http://bmorearty.wordpress.com/2008/06/18/find-tests-more-easily-in-your-testlog/#comment-49</link>
		<dc:creator>Brian</dc:creator>
		<pubDate>Sat, 25 Oct 2008 16:32:22 +0000</pubDate>
		<guid isPermaLink="false">http://bmorearty.wordpress.com/?p=19#comment-49</guid>
		<description>In an attempt to better understand monkey patching, I added a setup method to my test_helper.rb, as I understand it&#039;s called for each test.  It  worked, but I don&#039;t know how I didn&#039;t break the actual setup method.

def setup
  RAILS_DEFAULT_LOGGER.info &quot;\n\nStarting #{@method_name}\n#{&#039;-&#039; * (9 + @method_name.length)}\n&quot;  
end</description>
		<content:encoded><![CDATA[<p>In an attempt to better understand monkey patching, I added a setup method to my test_helper.rb, as I understand it&#8217;s called for each test.  It  worked, but I don&#8217;t know how I didn&#8217;t break the actual setup method.</p>
<p>def setup<br />
  RAILS_DEFAULT_LOGGER.info &#8220;\n\nStarting #{@method_name}\n#{&#8216;-&#8217; * (9 + @method_name.length)}\n&#8221;<br />
end</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brian Morearty</title>
		<link>http://bmorearty.wordpress.com/2008/06/18/find-tests-more-easily-in-your-testlog/#comment-45</link>
		<dc:creator>Brian Morearty</dc:creator>
		<pubDate>Thu, 02 Oct 2008 04:18:33 +0000</pubDate>
		<guid isPermaLink="false">http://bmorearty.wordpress.com/?p=19#comment-45</guid>
		<description>Hum, that&#039;s interesting, John. The call to setup is supposed to call a class method, not an instance method. (The doc page you referenced is referring to the instance method.) You might double-check to see if you entered it the way I wrote it.

Or perhaps things have changed in a newer version of Rails. (Or an older one.)

The code above works in Rails 2.0.2. There&#039;s a file called setup_and_teardown.rb that has these lines:

        base.send :include, ActiveSupport::Callbacks
        base.define_callbacks :setup, :teardown

define_callbacks creates a &quot;setup&quot; method and a &quot;teardown&quot; method as class methods. These methods are very much like the before_save, after_save, etc. methods, in that they take a parameter which is the name of a function to call before setup and after teardown. So my code that says &quot;setup :log_test&quot; tells the test framework to call the :log_test function before calling the &quot;setup&quot; instance method. 

Perhaps things work differently in other versions of Rails.</description>
		<content:encoded><![CDATA[<p>Hum, that&#8217;s interesting, John. The call to setup is supposed to call a class method, not an instance method. (The doc page you referenced is referring to the instance method.) You might double-check to see if you entered it the way I wrote it.</p>
<p>Or perhaps things have changed in a newer version of Rails. (Or an older one.)</p>
<p>The code above works in Rails 2.0.2. There&#8217;s a file called setup_and_teardown.rb that has these lines:</p>
<p>        base.send :include, ActiveSupport::Callbacks<br />
        base.define_callbacks :setup, :teardown</p>
<p>define_callbacks creates a &#8220;setup&#8221; method and a &#8220;teardown&#8221; method as class methods. These methods are very much like the before_save, after_save, etc. methods, in that they take a parameter which is the name of a function to call before setup and after teardown. So my code that says &#8220;setup :log_test&#8221; tells the test framework to call the :log_test function before calling the &#8220;setup&#8221; instance method. </p>
<p>Perhaps things work differently in other versions of Rails.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John</title>
		<link>http://bmorearty.wordpress.com/2008/06/18/find-tests-more-easily-in-your-testlog/#comment-44</link>
		<dc:creator>John</dc:creator>
		<pubDate>Wed, 01 Oct 2008 13:22:48 +0000</pubDate>
		<guid isPermaLink="false">http://bmorearty.wordpress.com/?p=19#comment-44</guid>
		<description>I tried this out but am getting an error, wrong number of arguments (1 for 0) for method setup.  Looking at the rdoc for the testcase class (http://www.ruby-doc.org/stdlib/libdoc/test/unit/rdoc/classes/Test/Unit/TestCase.html#M004534) and setup doesn&#039;t take any parameters.  Any ideas?</description>
		<content:encoded><![CDATA[<p>I tried this out but am getting an error, wrong number of arguments (1 for 0) for method setup.  Looking at the rdoc for the testcase class (<a href="http://www.ruby-doc.org/stdlib/libdoc/test/unit/rdoc/classes/Test/Unit/TestCase.html#M004534" rel="nofollow">http://www.ruby-doc.org/stdlib/libdoc/test/unit/rdoc/classes/Test/Unit/TestCase.html#M004534</a>) and setup doesn&#8217;t take any parameters.  Any ideas?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brian Morearty</title>
		<link>http://bmorearty.wordpress.com/2008/06/18/find-tests-more-easily-in-your-testlog/#comment-33</link>
		<dc:creator>Brian Morearty</dc:creator>
		<pubDate>Sat, 12 Jul 2008 04:38:27 +0000</pubDate>
		<guid isPermaLink="false">http://bmorearty.wordpress.com/?p=19#comment-33</guid>
		<description>Hmm. Mike, I haven&#039;t heard from anyone else who said they had that problem with an undefined method &#039;setup&#039;. Please drop another note here if you find a solution.</description>
		<content:encoded><![CDATA[<p>Hmm. Mike, I haven&#8217;t heard from anyone else who said they had that problem with an undefined method &#8217;setup&#8217;. Please drop another note here if you find a solution.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mike Boone</title>
		<link>http://bmorearty.wordpress.com/2008/06/18/find-tests-more-easily-in-your-testlog/#comment-32</link>
		<dc:creator>Mike Boone</dc:creator>
		<pubDate>Fri, 11 Jul 2008 20:24:46 +0000</pubDate>
		<guid isPermaLink="false">http://bmorearty.wordpress.com/?p=19#comment-32</guid>
		<description>Great idea.

I dropped the code into my Rails 2.0.2 app&#039;s test_helper.rb and got this error trying to run a unit test:

./test/unit/../test_helper.rb:42: undefined method `setup&#039; for Test::Unit::TestCase:Class (NoMethodError)

Anyone else seeing this?</description>
		<content:encoded><![CDATA[<p>Great idea.</p>
<p>I dropped the code into my Rails 2.0.2 app&#8217;s test_helper.rb and got this error trying to run a unit test:</p>
<p>./test/unit/../test_helper.rb:42: undefined method `setup&#8217; for Test::Unit::TestCase:Class (NoMethodError)</p>
<p>Anyone else seeing this?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brian Morearty</title>
		<link>http://bmorearty.wordpress.com/2008/06/18/find-tests-more-easily-in-your-testlog/#comment-31</link>
		<dc:creator>Brian Morearty</dc:creator>
		<pubDate>Fri, 04 Jul 2008 15:24:48 +0000</pubDate>
		<guid isPermaLink="false">http://bmorearty.wordpress.com/?p=19#comment-31</guid>
		<description>Thanks to Ben Mabey for that follow-up on how to do this in RSpec and to Gregg Pollack of RailsEnvy fame for pointing it out. I haven&#039;t used RSpec yet (although I&#039;m about to learn it since the team I just switched to at Intuit is using it), so I wasn&#039;t sure yet how to do my logging trick in RSpec.</description>
		<content:encoded><![CDATA[<p>Thanks to Ben Mabey for that follow-up on how to do this in RSpec and to Gregg Pollack of RailsEnvy fame for pointing it out. I haven&#8217;t used RSpec yet (although I&#8217;m about to learn it since the team I just switched to at Intuit is using it), so I wasn&#8217;t sure yet how to do my logging trick in RSpec.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gregg Pollack</title>
		<link>http://bmorearty.wordpress.com/2008/06/18/find-tests-more-easily-in-your-testlog/#comment-30</link>
		<dc:creator>Gregg Pollack</dc:creator>
		<pubDate>Fri, 04 Jul 2008 13:54:28 +0000</pubDate>
		<guid isPermaLink="false">http://bmorearty.wordpress.com/?p=19#comment-30</guid>
		<description>Ben Mabey wrote a follow up post showing how to do this in RSpec:

http://www.benmabey.com/2008/07/04/global-setup-in-rspec-or-how-to-add-logging-for-specs/

Happy July 4th!</description>
		<content:encoded><![CDATA[<p>Ben Mabey wrote a follow up post showing how to do this in RSpec:</p>
<p><a href="http://www.benmabey.com/2008/07/04/global-setup-in-rspec-or-how-to-add-logging-for-specs/" rel="nofollow">http://www.benmabey.com/2008/07/04/global-setup-in-rspec-or-how-to-add-logging-for-specs/</a></p>
<p>Happy July 4th!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ben.send :blog &#187; Blog Archive &#187; Global Setup In RSpec or How To Add Logging For Specs</title>
		<link>http://bmorearty.wordpress.com/2008/06/18/find-tests-more-easily-in-your-testlog/#comment-29</link>
		<dc:creator>ben.send :blog &#187; Blog Archive &#187; Global Setup In RSpec or How To Add Logging For Specs</dc:creator>
		<pubDate>Fri, 04 Jul 2008 08:09:30 +0000</pubDate>
		<guid isPermaLink="false">http://bmorearty.wordpress.com/?p=19#comment-29</guid>
		<description>[...] Morearty had an interesting post on how to add additional information to a rails testing log when using Test::Unit. The benefit of this is that you can quickly scan your log file when a test [...]</description>
		<content:encoded><![CDATA[<p>[...] Morearty had an interesting post on how to add additional information to a rails testing log when using Test::Unit. The benefit of this is that you can quickly scan your log file when a test [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brian Morearty</title>
		<link>http://bmorearty.wordpress.com/2008/06/18/find-tests-more-easily-in-your-testlog/#comment-28</link>
		<dc:creator>Brian Morearty</dc:creator>
		<pubDate>Tue, 01 Jul 2008 05:23:13 +0000</pubDate>
		<guid isPermaLink="false">http://bmorearty.wordpress.com/?p=19#comment-28</guid>
		<description>Thanks for the tip on the webrat gem, Jason. Looks good.</description>
		<content:encoded><![CDATA[<p>Thanks for the tip on the webrat gem, Jason. Looks good.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jason Boxman</title>
		<link>http://bmorearty.wordpress.com/2008/06/18/find-tests-more-easily-in-your-testlog/#comment-27</link>
		<dc:creator>Jason Boxman</dc:creator>
		<pubDate>Tue, 01 Jul 2008 02:34:03 +0000</pubDate>
		<guid isPermaLink="false">http://bmorearty.wordpress.com/?p=19#comment-27</guid>
		<description>Excellent.  I was just about to dig into that myself.  I am using shoulda and webrat and running through a bunch of controllers to verify they all status 200.  Now I can more easily spot which one failed and how.  Check out the webrat gem if you haven&#039;t yet -- it&#039;s great!</description>
		<content:encoded><![CDATA[<p>Excellent.  I was just about to dig into that myself.  I am using shoulda and webrat and running through a bunch of controllers to verify they all status 200.  Now I can more easily spot which one failed and how.  Check out the webrat gem if you haven&#8217;t yet &#8212; it&#8217;s great!</p>
]]></content:encoded>
	</item>
</channel>
</rss>
