November meeting topic - Testing Plugin

0 views
Skip to first unread message

Mike Hugo

unread,
Oct 9, 2008, 8:28:27 AM10/9/08
to Groovy Users of Minnesota
I am thinking about presenting on the new Grails Testing plugin. It's
been announced on the mailing list and I know there's some
documentation in the works (http://www.grails.org/Testing+Plugin), but
thought it'd be nice to dig in and put some examples together. I
can't make the October meeting, so I'm proposing this for November.
Would this be of interest to the group?

-Mike

ps- here are some of the posts about the plugin from the ML:
http://www.nabble.com/-ANN--Experimental-testing-plugin-td18530858.html
http://www.nabble.com/-ANN--Testing-Plugin-0.2-sneakily-released-td19624973.html

Justin Grammens

unread,
Oct 9, 2008, 9:20:16 AM10/9/08
to groo...@googlegroups.com
Definitely. +1 from me.

Jesse O'Neill-Oine

unread,
Oct 9, 2008, 9:54:25 AM10/9/08
to groo...@googlegroups.com
Yes, this is definitely of interest.  I would particularly be interested in some examples as well as a brief discussion about the plans for this plugin (if I'm not mistaken they are pulling it into Grails core for 1.1 or something).

Jesse

On Thu, Oct 9, 2008 at 7:28 AM, Mike Hugo <mi...@piragua.com> wrote:



--
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Jesse O'Neill-Oine // je...@refactr.com
Refactr LLC // http://refactr.com
mobile // 612-670-5037
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

Ted Naleid

unread,
Oct 9, 2008, 10:50:12 AM10/9/08
to groo...@googlegroups.com
I'd also like to see this.  I won't be able to be at the October meeting, but I'm planning on going to the November one.

-Ted

Todd McGrath

unread,
Oct 9, 2008, 5:01:07 PM10/9/08
to Groovy Users of Minnesota

Mike Hugo

unread,
Nov 11, 2008, 7:57:55 PM11/11/08
to Groovy Users of Minnesota

Ted Naleid

unread,
Nov 11, 2008, 8:11:43 PM11/11/08
to groo...@googlegroups.com
Sorry I wasn't able to be there Mike, looks like a great
presentation. Plus, I didn't get to find out what the "one more
thing..." at the end of the presentation was. :(

We're in the process of switching to use much more html (rather than
flex/flash) and the content you have here, along with your examples,
will be helpful. It's great that testing looks quite a bit speedier
with unit tests being able to exercise things that get decorated
dynamically by grails and were previously only available via
integration tests.

Thanks for putting this out there.

-Ted

Mike Hugo

unread,
Nov 11, 2008, 9:41:32 PM11/11/08
to groo...@googlegroups.com
No problem Ted, glad to hear it'll be helpful. The "one more thing"
is the beginnings of a plugin I'm thinking about that would 1)
generate tests for generated scaffolding in controllers and 2) stub
out constraints tests for a domain object.

Part 1 (albeit not in plugin form yet) is done already -
checkout
http://github.com/mjhugo/bookstore/tree/master

and run

grails generate-controller-test Author

and it will generate test/unit/AuthorControllerTests.groovy with all
the tests for your scaffolded controller. It's a good learning tool
for people new to Grails and to testing using the testing plugin. Not
very robust yet, but it's a starting point :)

Mike

Zan Thrash

unread,
Nov 12, 2008, 4:00:19 PM11/12/08
to groo...@googlegroups.com
Mike,

Great stuff. Thanks for posting this. I'm real sorry I missed last night.

Zan

Colin Harrington

unread,
Nov 16, 2008, 5:16:50 PM11/16/08
to groo...@googlegroups.com
Hey Mike,

In your presentation, I thought you were able to right-click and run the unit tests, I'm having trouble getting that to work correctly.  Every time I click the "Run <artefact>Test" in the context menu, it tries to run the test via grails instead of JUnit. I remember that you said something about editing your configurations, but was unsure what you did.

How do you get it to quickly run the test via JUnit in Intellij?  is there a key-combo that gets you there?

Great Presentation!

Colin

Mike Hugo

unread,
Nov 16, 2008, 5:34:52 PM11/16/08
to groo...@googlegroups.com
Hi Colin,

You need to edit the configurations to run the class as a unit test.  Haven't found out a keystroke for it yet so if you find one, let me know.  Here's how I've been doing it lately:  http://www.screencast.com/t/zF7Qsuj2U

Mike

Mike Hugo

unread,
Nov 16, 2008, 8:53:38 PM11/16/08
to Groovy Users of Minnesota
So, as promised, I've created a "test-template" plugin that will
1) Generate controller unit test cases automatically when you generate
scaffolded controllers (provided you're using Grails 1.0.4)
2) Stub out a unit test case for a given domain class (no, it doesn't
write the test code for you (yet), but it does create several test
methods for you to fill in)

Check out the details at
http://www.piragua.com/2008/11/16/added-generate-unit-test-case-script-to-test-template-plugin/
or http://www.grails.org/TestTemplate+Plugin

It even has cool things like support for packages (you are using
packages in your grails apps, right?) and the 'uber-generate' feature
of Grails 1.0.4 (create a bunch of domain classes and then run grails
generate-all "*" and grails generate-domain-unit-test "*" - c'mon, I
dare you).

You can install it by running:
grails install-plugin testing
grails install-plugin test-template

(the first line is required because the test-template plugin relies on
the testing plugin. if you already have the testing plugin installed
you don't need to run that one first).

Happy testing,
Mike

On Nov 11, 8:41 pm, Mike Hugo <m...@piragua.com> wrote:
> No problem Ted, glad to hear it'll be helpful.  The "one more thing"  
> is the beginnings of a plugin I'm thinking about that would 1)  
> generate tests for generated scaffolding in controllers and 2) stub  
> out constraints tests for a domain object.
>
> Part 1 (albeit not in plugin form yet) is done already -
> checkouthttp://github.com/mjhugo/bookstore/tree/master
> >>> ps- here are some of the posts about the plugin from the ML:http://www.nabble.com/-ANN--Experimental-testing-plugin-td18530858.ht...
> >>> ...
Reply all
Reply to author
Forward
0 new messages