<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Elliot Loves Perl &#187; testing</title>
	<atom:link href="http://elliotlovesperl.com/tag/testing/feed/" rel="self" type="application/rss+xml" />
	<link>http://elliotlovesperl.com</link>
	<description>A boy and his language</description>
	<lastBuildDate>Wed, 17 Feb 2010 12:43:40 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='elliotlovesperl.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://1.gravatar.com/blavatar/7899c71f1e2dd5c5fa1b1ec047ffdf34?s=96&#038;d=http://s2.wp.com/i/buttonw-com.png</url>
		<title>Elliot Loves Perl &#187; testing</title>
		<link>http://elliotlovesperl.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://elliotlovesperl.com/osd.xml" title="Elliot Loves Perl" />
	<atom:link rel='hub' href='http://elliotlovesperl.com/?pushpress=hub'/>
		<item>
		<title>Test Moose accessors? Hell, yes.</title>
		<link>http://elliotlovesperl.com/2010/02/16/test-moose-accessors-hell-yes/</link>
		<comments>http://elliotlovesperl.com/2010/02/16/test-moose-accessors-hell-yes/#comments</comments>
		<pubDate>Wed, 17 Feb 2010 02:36:13 +0000</pubDate>
		<dc:creator>elliotlovesperl</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[Moose]]></category>
		<category><![CDATA[Test::Moose]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://elliotlovesperl.wordpress.com/?p=158</guid>
		<description><![CDATA[I&#8217;m sorry Dave, but you&#8217;re wrong, wrong, wrong! :] The purpose of testing &#8220;attributes&#8221; is not to test that Moose did its thing. The purpose of testing attributes&#8217; accessors is that they are part of your class&#8217; interface. That an accessor is backed by a Moose attribute is an implementation detail. Just because get_foo() is [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=elliotlovesperl.com&amp;blog=7775865&amp;post=158&amp;subd=elliotlovesperl&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m sorry Dave, but <a href="http://blog.urth.org/2010/02/the-purpose-of-automated-tests.html">you&#8217;re wrong, wrong, wrong</a>! :]</p>
<p>
The purpose of testing &#8220;attributes&#8221; is not to test that Moose did its thing.  The purpose of testing attributes&#8217; accessors is that they are part of your class&#8217; interface.  That an accessor is backed by a Moose attribute is an implementation detail.  Just because <code>get_foo()</code> is an attribute accessor today doesn&#8217;t mean that the data won&#8217;t be stored elsewhere in the future or even be derived from something else.</p>
<p>
What you shouldn&#8217;t be doing is using <code>has_attribute_ok()</code> from Test::Moose, again because where the data returned by the accessor is coming from shouldn&#8217;t matter to users of your class.</p>
<br /> Tagged: <a href='http://elliotlovesperl.com/tag/development/'>development</a>, <a href='http://elliotlovesperl.com/tag/moose/'>Moose</a>, <a href='http://elliotlovesperl.com/tag/testmoose/'>Test::Moose</a>, <a href='http://elliotlovesperl.com/tag/testing/'>testing</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/elliotlovesperl.wordpress.com/158/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/elliotlovesperl.wordpress.com/158/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/elliotlovesperl.wordpress.com/158/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/elliotlovesperl.wordpress.com/158/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/elliotlovesperl.wordpress.com/158/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/elliotlovesperl.wordpress.com/158/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/elliotlovesperl.wordpress.com/158/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/elliotlovesperl.wordpress.com/158/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/elliotlovesperl.wordpress.com/158/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/elliotlovesperl.wordpress.com/158/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/elliotlovesperl.wordpress.com/158/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/elliotlovesperl.wordpress.com/158/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/elliotlovesperl.wordpress.com/158/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/elliotlovesperl.wordpress.com/158/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=elliotlovesperl.com&amp;blog=7775865&amp;post=158&amp;subd=elliotlovesperl&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://elliotlovesperl.com/2010/02/16/test-moose-accessors-hell-yes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e2e2e6430cc24b91f3c25f25fba6d9e6?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">elliotlovesperl</media:title>
		</media:content>
	</item>
		<item>
		<title>Explicitly running author tests.</title>
		<link>http://elliotlovesperl.com/2009/11/24/explicitly-running-author-tests/</link>
		<comments>http://elliotlovesperl.com/2009/11/24/explicitly-running-author-tests/#comments</comments>
		<pubDate>Tue, 24 Nov 2009 20:23:44 +0000</pubDate>
		<dc:creator>elliotlovesperl</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[CPAN module support]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://elliotlovesperl.wordpress.com/?p=150</guid>
		<description><![CDATA[There are tests that you want to have around, but not be part of the standard test run prior to installation of a distribution. Probably the biggest set of these in publicly available Perl distributions is &#8220;author&#8221; tests (manifest checks, code and POD coverage, etc.), but there are other things such as live database tests [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=elliotlovesperl.com&amp;blog=7775865&amp;post=150&amp;subd=elliotlovesperl&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>There are tests that you want to have around, but not be part of the standard test run prior to installation of a distribution.  Probably the biggest set of these in publicly available Perl distributions is &#8220;author&#8221; tests (manifest checks, code and POD coverage, etc.), but there are other things such as live database tests that should not block installation.  The most common way of disabling tests is via checking an environment variable in a test file:</p>
<div style="background-color:#333;margin:1em 2em;">
<font face="monospace"><br />
<font color="#ff0">1 </font><font color="#f0e68c"><b>if</b></font>&nbsp;( <font color="#f0e68c"><b>not</b></font>&nbsp;<font color="#98fb98">$ENV</font>{TEST_AUTHOR}) {<br />
<font color="#ff0">2 </font>&nbsp;&nbsp;&nbsp;&nbsp;plan <font color="#ffa0a0">skip_all </font>=&gt; <font color="#ffa0a0">&#8216;</font><font color="#ffa0a0">Author test. Set $ENV{TEST_AUTHOR} to a true value to run.</font><font color="#ffa0a0">&#8216;</font>;<br />
<font color="#ff0">3 </font>}<br />
</font>
</div>
<p>On the Perl::Critic project, we ran into problems with this.  We got failures when people had the environment variable set for their own purposes.  The code that checked for enabling author tests also turned them on if there was a <code>.svn</code> directory around, so, of course, we got a complaint when someone grabbed the source from the Perl::Critic repository. *sigh*</p>
<p>The proper way to enable author tests is to require the user to explicitly say that she wants them to be run.</p>
<p>The first thing to do is to segregate the non-standard tests from the regular ones so that the standard testing tools don&#8217;t run them by default.  At the 2008 QA hackathon in Oslo it was decided that these tests belong under the &#8220;xt&#8221; directory in a distribution; there was no mandate about substructure.  I&#8217;ve been using &#8220;xt/author&#8221; for my author tests.</p>
<p>The second step is to create a &#8220;authortest&#8221; build target.  Since I use <a href="http://search.cpan.org/perldoc/Module::Build">Module::Build</a> as my build tool, this example will use that.  The way to create a custom target in Module::Build is to create a method on a Module::Build subclass with a name that starts with &#8220;ACTION_&#8221;.  Here&#8217;s my standard &#8220;authortest&#8221; code:</p>
<div style="background-color:#333;margin:1em 2em;">
<font face="monospace"><br />
<font color="#ff0">&nbsp;1 </font><font color="#f0e68c"><b>sub</b></font><font color="#98fb98">&nbsp;</font><font color="#98fb98">ACTION_authortest </font>{<br />
<font color="#ff0">&nbsp;2 </font>&nbsp;&nbsp;&nbsp;&nbsp;<font color="#f0e68c"><b>my</b></font>&nbsp;(<font color="#98fb98">$self</font>) = <font color="#98fb98">@_</font>;<br />
<font color="#ff0">&nbsp;3 </font><br />
<font color="#ff0">&nbsp;4 </font>&nbsp;&nbsp;&nbsp;&nbsp;<font color="#98fb98">$self</font>-&gt;depends_on(<font color="#ffa0a0">&#8216;</font><font color="#ffa0a0">build</font><font color="#ffa0a0">&#8216;</font>);<br />
<font color="#ff0">&nbsp;5 </font>&nbsp;&nbsp;&nbsp;&nbsp;<font color="#98fb98">$self</font>-&gt;depends_on(<font color="#ffa0a0">&#8216;</font><font color="#ffa0a0">manifest</font><font color="#ffa0a0">&#8216;</font>);<br />
<font color="#ff0">&nbsp;6 </font>&nbsp;&nbsp;&nbsp;&nbsp;<font color="#98fb98">$self</font>-&gt;depends_on(<font color="#ffa0a0">&#8216;</font><font color="#ffa0a0">distmeta</font><font color="#ffa0a0">&#8216;</font>);<br />
<font color="#ff0">&nbsp;7 </font><br />
<font color="#ff0">&nbsp;8 </font>&nbsp;&nbsp;&nbsp;&nbsp;<font color="#98fb98">$self</font>-&gt;test_files( <font color="#ffa0a0">qw&lt;</font><font color="#ffa0a0">&nbsp;t xt/author </font><font color="#ffa0a0">&gt;</font>&nbsp;);<br />
<font color="#ff0">&nbsp;9 </font>&nbsp;&nbsp;&nbsp;&nbsp;<font color="#98fb98">$self</font>-&gt;recursive_test_files(<font color="#ffa0a0">1</font>);<br />
<font color="#ff0">10 </font><br />
<font color="#ff0">11 </font>&nbsp;&nbsp;&nbsp;&nbsp;<font color="#98fb98">$self</font>-&gt;depends_on(<font color="#ffa0a0">&#8216;</font><font color="#ffa0a0">test</font><font color="#ffa0a0">&#8216;</font>);<br />
<font color="#ff0">12 </font><br />
<font color="#ff0">13 </font>&nbsp;&nbsp;&nbsp;&nbsp;<font color="#f0e68c"><b>return</b></font>;<br />
<font color="#ff0">14 </font>}<br />
</font>
</div>
<p>First this asks Module::Build to ensure that the build, manifest, and distmeta actions have been run because some of the tests depend upon the MANIFEST and META.yml files being around and I don&#8217;t check those into source control.  Line 8 tells Module::Build to look in the standard &#8220;t&#8221; directory plus &#8220;xt/author&#8221; for tests.  Line 9 says that the test files may not be directly in these subdirectories.  Finally, it asks for the regular test action to be run.</p>
<p>Using this, running the standard &#8220;<code>./Build test</code>&#8221; command doesn&#8217;t run author tests, no matter what the user&#8217;s environment is.  And simply running &#8220;<code>./Build authortest</code>&#8221; causes all the tests to run.  Simple, yet explicit.</p>
<p>To ensure that nothing gets released without the author tests being run, I change the distdir action to require the author tests be run:</p>
<div style="background-color:#333;margin:1em 2em;">
<font face="monospace"><br />
<font color="#ff0">1 </font><font color="#f0e68c"><b>sub</b></font><font color="#98fb98">&nbsp;</font><font color="#98fb98">ACTION_distdir </font>{<br />
<font color="#ff0">2 </font>&nbsp;&nbsp;&nbsp;&nbsp;<font color="#f0e68c"><b>my</b></font>&nbsp;(<font color="#98fb98">$self</font>) = <font color="#98fb98">@_</font>;<br />
<font color="#ff0">3 </font><br />
<font color="#ff0">4 </font>&nbsp;&nbsp;&nbsp;&nbsp;<font color="#98fb98">$self</font>-&gt;depends_on(<font color="#ffa0a0">&#8216;</font><font color="#ffa0a0">authortest</font><font color="#ffa0a0">&#8216;</font>);<br />
<font color="#ff0">5 </font><br />
<font color="#ff0">6 </font>&nbsp;&nbsp;&nbsp;&nbsp;<font color="#f0e68c"><b>return</b></font>&nbsp;<font color="#98fb98">$self</font>-&gt;SUPER::ACTION_distdir();<br />
<font color="#ff0">7 </font>}<br />
</font>
</div>
<br /> Tagged: CPAN module support, testing <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/elliotlovesperl.wordpress.com/150/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/elliotlovesperl.wordpress.com/150/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/elliotlovesperl.wordpress.com/150/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/elliotlovesperl.wordpress.com/150/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/elliotlovesperl.wordpress.com/150/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/elliotlovesperl.wordpress.com/150/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/elliotlovesperl.wordpress.com/150/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/elliotlovesperl.wordpress.com/150/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/elliotlovesperl.wordpress.com/150/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/elliotlovesperl.wordpress.com/150/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/elliotlovesperl.wordpress.com/150/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/elliotlovesperl.wordpress.com/150/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/elliotlovesperl.wordpress.com/150/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/elliotlovesperl.wordpress.com/150/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=elliotlovesperl.com&amp;blog=7775865&amp;post=150&amp;subd=elliotlovesperl&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://elliotlovesperl.com/2009/11/24/explicitly-running-author-tests/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e2e2e6430cc24b91f3c25f25fba6d9e6?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">elliotlovesperl</media:title>
		</media:content>
	</item>
	</channel>
</rss>