<?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/"
	>

<channel>
	<title>Piraguablog &#187; plugin</title>
	<atom:link href="http://www.piragua.com/category/plugin/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.piragua.com</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Tue, 22 Jun 2010 22:03:49 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>One week with WhenWorksForYou.com</title>
		<link>http://www.piragua.com/2009/07/13/one-week-with-whenworksforyoucom/</link>
		<comments>http://www.piragua.com/2009/07/13/one-week-with-whenworksforyoucom/#comments</comments>
		<pubDate>Mon, 13 Jul 2009 11:25:07 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[grails]]></category>
		<category><![CDATA[groovy]]></category>
		<category><![CDATA[plugin]]></category>

		<guid isPermaLink="false">http://www.piragua.com/?p=37</guid>
		<description><![CDATA[Last week I launched http://www.whenworksforyou.com, a new Grails website that lets you coordinate schedules with other people to find the best date for your next event.  Our first week provided lots of great feedback from users.  One of the biggest gripes was not being able to subscribe to updates on an event.  [...]]]></description>
			<content:encoded><![CDATA[<p>Last week I launched <a href="http://www.whenworksforyou.com" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.whenworksforyou.com');">http://www.whenworksforyou.com</a>, a new Grails website that lets you coordinate schedules with other people to find the best date for your next event.  Our first week provided lots of great feedback from users.  One of the biggest gripes was not being able to subscribe to updates on an event.  Well, thanks to the <a href="http://grails.org/plugin/feeds" onclick="javascript:pageTracker._trackPageview('/outbound/article/grails.org');">feeds</a> and <a href="http://grails.org/plugin/mail" onclick="javascript:pageTracker._trackPageview('/outbound/article/grails.org');">mail</a> plugins, now you can!  It was dead simple to implement, and now I can focus my attention on the next feature rather than having to re-invent the wheel on RSS and email.</p>
<p>The site also takes advantage of several other plugins, including</p>
<ul>
<li><a href="http://grails.org/plugin/acegi" onclick="javascript:pageTracker._trackPageview('/outbound/article/grails.org');">Spring Security</a></li>
<li><a href="http://grails.org/plugin/ui-performance" onclick="javascript:pageTracker._trackPageview('/outbound/article/grails.org');">UI Performance</a></li>
<li><a href="http://grails.org/plugin/recaptcha" onclick="javascript:pageTracker._trackPageview('/outbound/article/grails.org');">Recaptcha</a></li>
<li><a href="http://grails.org/plugin/build-test-data" onclick="javascript:pageTracker._trackPageview('/outbound/article/grails.org');">Build Test Data</a></li>
<li>Test Code Coverage (of course)</li>
</ul>
<p>Thanks to all the plugin developers who took the time to build and document plugins for the Grails framework!</p>
<p>I also wrote one other plugin that wraps GreenMail and acts as a transient &#8220;Inbox&#8221; for sending emails during development.  I&#8217;m putting the finishing touches on that now, stay tuned for more information.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.piragua.com/2009/07/13/one-week-with-whenworksforyoucom/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Grails Code-Coverage plugin updated to run with Grails 1.1</title>
		<link>http://www.piragua.com/2009/01/12/grails-code-coverage-plugin-updated-to-run-with-grails-11/</link>
		<comments>http://www.piragua.com/2009/01/12/grails-code-coverage-plugin-updated-to-run-with-grails-11/#comments</comments>
		<pubDate>Tue, 13 Jan 2009 04:01:16 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[grails]]></category>
		<category><![CDATA[plugin]]></category>

		<guid isPermaLink="false">http://www.piragua.com/?p=32</guid>
		<description><![CDATA[I&#8217;ve made some changes to the Grails code-coverage plugin to support Grails 1.1.  If you&#8217;re using Grails 1.1-beta2, you can try it out by running grails install-plugin code-coverage.  
Documentation can be found at http://www.grails.org/Test+Code+Coverage+Plugin
]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve made some changes to the Grails code-coverage plugin to support Grails 1.1.  If you&#8217;re using Grails 1.1-beta2, you can try it out by running <code>grails install-plugin code-coverage</code>.  </p>
<p>Documentation can be found at <a href="http://www.grails.org/Test+Code+Coverage+Plugin" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.grails.org');">http://www.grails.org/Test+Code+Coverage+Plugin</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.piragua.com/2009/01/12/grails-code-coverage-plugin-updated-to-run-with-grails-11/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Controller.$_closure1 &#8211; what?  Oh, you mean .index()!</title>
		<link>http://www.piragua.com/2008/11/20/controller_closure1-what-oh-you-mean-index/</link>
		<comments>http://www.piragua.com/2008/11/20/controller_closure1-what-oh-you-mean-index/#comments</comments>
		<pubDate>Fri, 21 Nov 2008 04:19:25 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[grails]]></category>
		<category><![CDATA[plugin]]></category>

		<guid isPermaLink="false">http://www.piragua.com/?p=25</guid>
		<description><![CDATA[So it&#8217;s been bugging me for a while that the action names within a controller always showed up like this on my code coverage reports:

Well, no longer!  Version 0.9 of the Grails Code Coverage plugin now does some post processing on the Cobertura reports that replace the Controller.$_closure1 ugliness with the matching action name:

It&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<p>So it&#8217;s been bugging me for a while that the action names within a controller always showed up like this on my code coverage reports:<br />
<a href="http://www.piragua.com/wp-content/uploads/2008/11/oldclosurename1.png" ><img class="alignnone size-full wp-image-27" style="border: 1px solid black;" title="Yeck - $_closure1 doesn\'t tell me anything!" src="http://www.piragua.com/wp-content/uploads/2008/11/oldclosurename1.png" alt="" width="276" height="198" /></a><br />
Well, no longer!  Version 0.9 of the Grails Code Coverage plugin now does some post processing on the Cobertura reports that replace the Controller.$_closure1 ugliness with the matching action name:</p>
<p><a href="http://www.piragua.com/wp-content/uploads/2008/11/newclosurename.png" ><img class="alignnone size-full wp-image-24" style="border: 1px solid black;" title="Brave new world!  Readable action names" src="http://www.piragua.com/wp-content/uploads/2008/11/newclosurename.png" alt="" width="412" height="318" /></a></p>
<p>It&#8217;s not the most efficient post processing in the world &#8211; I&#8217;m basically iterating through all the controller actions and then replacing all occurrences of those class names with the action names in the report HTML files.  If you find the post processing to be too annoying, you can turn it off by passing the &#8220;<code>-nopost</code>&#8221; argument to the command, like this:</p>
<pre>grails test-app-cobertura -nopost</pre>
<p>Thanks to <a href="http://burtbeckwith.com/blog/" onclick="javascript:pageTracker._trackPageview('/outbound/article/burtbeckwith.com');">Burt Beckwith</a> and others on the grails mailing list for <a href="http://www.nabble.com/Code-coverage-reports---finding-name-of-closure-td20601600.html" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.nabble.com');">proposing options</a> on how to line up the closure class names with the variable names to which they are assigned in the controller.</p>
<p>It only works for the HTML reports right now&#8230;I&#8217;ll work on adding it to the XML version of the reports next.</p>
<p>To install the plugin, type the following command:</p>
<pre>
grails install-plugin code-coverage
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.piragua.com/2008/11/20/controller_closure1-what-oh-you-mean-index/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Added generate-unit-test-case script to Test Template plugin</title>
		<link>http://www.piragua.com/2008/11/16/added-generate-unit-test-case-script-to-test-template-plugin/</link>
		<comments>http://www.piragua.com/2008/11/16/added-generate-unit-test-case-script-to-test-template-plugin/#comments</comments>
		<pubDate>Mon, 17 Nov 2008 01:46:22 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[grails]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://www.piragua.com/?p=18</guid>
		<description><![CDATA[As pointed out in the docs for the Grails Testing Plugin, constraints often contain a lot of logic for your application and are rarely tested. To help out with that, the Test Template plugin now provides a script that will create a stub of a unit test for you for a given domain class.
For example, [...]]]></description>
			<content:encoded><![CDATA[<p>As pointed out in the docs for the <a href="http://www.grails.org/Testing+Plugin#mockForConstraintsTests(class, testInstances = [])" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.grails.org');">Grails Testing Plugin</a>, constraints often contain a lot of logic for your application and are rarely tested. To help out with that, the Test Template plugin now provides a script that will create a stub of a unit test for you for a given domain class.<br />
For example, say you had the following domain class:</p>

<div class="wp_syntax"><div class="code"><pre class="groovy"><span style="color: #000000; font-weight: bold;">class</span> <span style="color: #aaaadd; font-weight: bold;">Book</span> <span style="color: #66cc66;">&#123;</span>
	<span style="color: #aaaadd; font-weight: bold;">String</span> title
	<span style="color: #aaaadd; font-weight: bold;">String</span> subTitle
	<span style="color: #aaaadd; font-weight: bold;">Date</span> publishedDate
	<span style="color: #000000; font-weight: bold;">static</span> constraints <span style="color: #66cc66;">=</span> <span style="color: #66cc66;">&#123;</span>
		title<span style="color: #66cc66;">&#40;</span>nullable:<span style="color: #000000; font-weight: bold;">false</span>, blank:<span style="color: #000000; font-weight: bold;">false</span>, <span style="color: #663399;">size</span>:<span style="color: #cc66cc;">1</span>..<span style="color: #cc66cc;">100</span><span style="color: #66cc66;">&#41;</span>
		publishedDate<span style="color: #66cc66;">&#40;</span>nullable:<span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">&#41;</span>
	<span style="color: #66cc66;">&#125;</span>	
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>With the plugin installed, type &#8220;grails generate-domain-unit-test Book&#8221;</p>
<p>The plugin will generate and stub out a unit test for you in test/unit/BookUnitTests.groovy. It&#8217;s not completely magic &#8211; you still need to do some work now:</p>
<ul>
<li>in the setup method, fill in all the properties that would make your domain class validate</li>
<li>in each test method, write test code that will test your constraints. The plugin provides comments indicating which constraints are applied to a given property, you just need to write the test code.</li>
</ul>
<p>Here&#8217;s what a stubbed unit test looks like out of the box:</p>

<div class="wp_syntax"><div class="code"><pre class="groovy"><span style="color: #a1a100;">import grails.test.GrailsUnitTestCase</span>
<span style="color: #000000; font-weight: bold;">class</span> BookUnitTests <span style="color: #000000; font-weight: bold;">extends</span> GrailsUnitTestCase <span style="color: #66cc66;">&#123;</span>
    <span style="color: #aaaadd; font-weight: bold;">Book</span> book 
    <span style="color: #993333;">void</span> setUp<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">super</span>.<span style="color: #006600;">setUp</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
        <span style="color: #808080; font-style: italic;">// in testing-plugin 0.4 you can just do &quot;mockForConstraintsTests(Book)&quot; instead of these two lines</span>
        registerMetaClass<span style="color: #66cc66;">&#40;</span><span style="color: #aaaadd; font-weight: bold;">Book</span><span style="color: #66cc66;">&#41;</span> 
        grails.<span style="color: #006600;">test</span>.<span style="color: #006600;">MockUtils</span>.<span style="color: #006600;">prepareForConstraintsTests</span><span style="color: #66cc66;">&#40;</span><span style="color: #aaaadd; font-weight: bold;">Book</span><span style="color: #66cc66;">&#41;</span>
	<span style="color: #808080; font-style: italic;">// TODO - fill out this book instance so it validates</span>
	book <span style="color: #66cc66;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #aaaadd; font-weight: bold;">Book</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
        assertTrue <span style="color: #ff0000;">&quot;setup method: book should validate&quot;</span>, 
			book.<span style="color: #006600;">validate</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
        <span style="color: #66cc66;">&#125;</span>
	<span style="color: #993333;">void</span> testTitleConstriants<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>		 
		<span style="color: #808080; font-style: italic;">//test org.codehaus.groovy.grails.validation.NullableConstraint@de1237[false]  </span>
		<span style="color: #808080; font-style: italic;">//test org.codehaus.groovy.grails.validation.BlankConstraint@7bc5fd[false]  </span>
		<span style="color: #808080; font-style: italic;">//test org.codehaus.groovy.grails.validation.SizeConstraint@36f09[1..100] </span>
	<span style="color: #66cc66;">&#125;</span>	
	<span style="color: #993333;">void</span> testPublishedDateConstriants<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>		
		<span style="color: #808080; font-style: italic;">//test org.codehaus.groovy.grails.validation.NullableConstraint@6ec9d4[true] </span>
	<span style="color: #66cc66;">&#125;</span>	
	<span style="color: #993333;">void</span> testSubTitleConstriants<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>		
		<span style="color: #808080; font-style: italic;">//test org.codehaus.groovy.grails.validation.NullableConstraint@849937[false] </span>
	<span style="color: #66cc66;">&#125;</span>	
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>This is helpful in reminding you what you actually need to test &#8211; for example, did you remember that by not defining a constraint for the &#8217;subTitle&#8217; property, grails makes it a non-nullable field?  </p>
<p>By the way, the script also works with the uber generate feature of Grails 1.0.4 &#8211; so if you have lots of domain classes and want to generate unit tests for all of them in one fell swoop, you can type:</p>
<pre>
grails generate-domain-unit-test "*"
</pre>
<p>and it will stub out unit tests for all your domain classes.</p>
<p>I&#8217;m thinking future versions of the plugin could go even further by offering:</p>
<ul>
<li>A &#8216;verbose&#8217; template that would create multiple test methods for each possible test scenario for a given constraint, for instance a &#8217;size:5..100&#8242; constraint could generate test methods for:</li>
<ul>
<li>a string with a size of 4 (e.g. less than the minimum)</li>
<li>a string with a size of 101 (e.g. more than the maximum)</li>
<li>a string with a size of 50 (e.g. within the bounds of the constraint)</li>
</ul>
<li>Actually write the test code.  Not sure if I&#8217;m totally warmed up to this idea yet, but it may be worth looking into.  Contributions welcome, of course <img src='http://www.piragua.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </li>
</ul>
<p>Give it a shot.  You can install the plugin by running the following commands:</p>
<pre>
grails install-plugin testing
grails install-plugin test-template
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.piragua.com/2008/11/16/added-generate-unit-test-case-script-to-test-template-plugin/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Generated Controller Test Cases</title>
		<link>http://www.piragua.com/2008/11/16/generated-controller-test-cases/</link>
		<comments>http://www.piragua.com/2008/11/16/generated-controller-test-cases/#comments</comments>
		<pubDate>Sun, 16 Nov 2008 15:04:11 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[grails]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://www.piragua.com/?p=17</guid>
		<description><![CDATA[The generated controller scaffolding from Grails is a great tool for learning the framework quickly.  It provides examples of controllers, controller actions, simple GORM methods on your domain classes, Groovy Server Pages and tag libraries &#8211; everything you need to get started &#8211; EXCEPT for how to unit test the stuff.
I&#8217;ve always thought a [...]]]></description>
			<content:encoded><![CDATA[<p>The generated controller scaffolding from Grails is a great tool for learning the framework quickly.  It provides examples of controllers, controller actions, simple GORM methods on your domain classes, Groovy Server Pages and tag libraries &#8211; everything you need to get started &#8211; EXCEPT for how to unit test the stuff.</p>
<p>I&#8217;ve always thought a good addition to Grails would be the ability to generate unit tests for all that scaffolding code in your generated controllers.  With the advent of testing enhancements coming to Grails 1.1 and the <a href="http://www.grails.org/Testing+Plugin" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.grails.org');">Grails Testing Plugin</a> making it much easier to unit test Grails artifacts, this is more of a reality.</p>
<p>So I buckled down and created a plugin with a template for testing generated controllers.  If you&#8217;re on Grails 1.0.4, it hooks directly into events in the build system to create the unit test file automagically.  If you haven&#8217;t upgraded yet and you&#8217;re still on Grails 1.0.3, there&#8217;s a script you can call to generate the unit test manually.</p>
<p>I decided to make the Testing Plugin a pre-requisite for the &#8220;Test Template&#8221; plugin, since it makes the test code SO much easier to write.  So to get started, run &#8220;<strong>grails install-plugin testing</strong>&#8220;, followed by &#8220;<strong>grails install-plugin test-template</strong>&#8220;.  Here&#8217;s an small example:</p>
<pre>
grails create-app bookstore
cd bookstore
grails install-plugin testing
grails install-plugin test-template
grails create-domain-class Book
grails generate-controller Book (or you could run generate-all Book)
</pre>
<p>If you have Grails 1.0.4, that last line will generate the controller for you AND also generate a unit test (test/unit/BookControllerUnitTests.groovy).  The unit test will have test methods for each controller action, with several test methods for each of the actions that have if/else statements in them.  </p>
<p>If you have Grails 1.0.3, you have to manually generate the unit test, which you can do with this line:</p>
<pre>
grails generate-controller-unit-test Book
</pre>
<p>Yes, that&#8217;s a long command name, but what are you doing still on Grails 1.0.3 anyway?  Grails 1.0.4 has been out for like 48 hours &#8211; go upgrade already!</p>
<p>Now run your test suite (grails test-app) and watch your newly generated tests scroll by!</p>
<p>The plugin uses the createArtefact method in Init.groovy, so it also handles packages:</p>
<pre>
grails create-domain-class com.pirgaua.Book
grails generate-controller com.piragua.Book
// -> generates test/unit/com/piragua/BookControllerUnitTests.groovy
</pre>
<p>And, it also handles the new &#8220;uber-generate&#8221; feature in 1.0.4 (courtesy of <a href="http://marceloverdijk.blogspot.com/2008/05/uber-generate-all.html" onclick="javascript:pageTracker._trackPageview('/outbound/article/marceloverdijk.blogspot.com');">Marcel Overdijk</a> and <a href="http://jira.codehaus.org/browse/GRAILS-2946" onclick="javascript:pageTracker._trackPageview('/outbound/article/jira.codehaus.org');">GRAILS-2946</a>:</p>
<pre>
grails create-domain-class Book
grails create-domain-class Author
grails create-domain-class Store
grails create-domain-class Cart
// edit your domain classes and add properties, constraints, etc...
grails generate-all "*"
// -> generates controllers, views, and controller unit tests for ALL your domain classes
</pre>
<p>And you can override the plugin provided template, just run &#8220;grails install-test-templates&#8221; and modify the template code to suit your own needs (the templates are copied to src/templates/artifacts/test-templates).</p>
<p>Speaking of the next version &#8211; the next feature I want to add to the plugin is a way to generate a unit test for testing domain constraints.  Stay tuned!</p>
<p>More documentation on the <a href="http://www.grails.org/TestTemplate+Plugin" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.grails.org');">Test Template</a> plugin page at grails.org</p>
]]></content:encoded>
			<wfw:commentRss>http://www.piragua.com/2008/11/16/generated-controller-test-cases/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
