SpringOne 2GX 2011

Chicago, October 25-28, 2011

Griffon 0.9 sneak peek: testing upgrades

Posted by: Andres Almiray on 07/06/2010
Continuing the peek parade (previous entries on command line features and application archetypes) we'll look at what's new regarding testing in Griffon.

The first thing you'll notice is that executing tests is done in the same way as in Grails. This is because Griffon's build system has been refreshed with the latest Grails 1.3.2 codebase. Now you can run all tests using the same phase:type mechanism that Grails has. Griffon has 3 phases (unit, integration and other) and two default types (unit and integration). Those two types are actually JUnit based tests cases, it has been pointed out that perhaps those types should be coalesced into a single one: junit.

Say you'd like to run all JUnit tests in the unit phase, this is what you must type
griffon test-app :unit
On the other hand, if what you want is to exercise all unit tests regardless of their type, then invoke the following command
griffon test-app unit:
Speaking of types, there are two additional types provided by plugins. The first type is easyb and the second is spock. Both plugins are direct port of their corresponding Grails counterparts (which speaks volumes in terms of compatibility between Grails and Griffon, doesn't it?). New versions of these plugins will be ready once Griffon 0.9 ships.

Back to test-app. this command is very flexible with its options. Do you need to run all tests that affect all services?
griffon test-app *Service
What if what you want is to run all tests that are related to the same artifact?
griffon test-app FooController
You can also specify package names and even run a single test method, like this
griffon test-app com.acme.Factory.testMakeAnvil
All this is possible to the great efforts made by Luke Daley in the Grails codebase (with a big help from the rest of the Grails team too: Graeme, Peter, Jeff and Burt).

Following into testing related plugins, there are 4 other direct ports of Grails plugins into Griffon
  • Code-Coverage - this one existed since the early days, however it has been synchronized to the latest codebase from its Grails counterpart
  • Clover - s/grails/griffon/ did the trick for this one, just like that.
  • CodeNarc - static code analysis for Groovy source? you bet!
  • GMetrics - measures the size and complexity of your codebase
The FEST plugin has been upgraded to FEST 1.2 and received a major facelift, it even provides an Spock spec in case you'd like to mix Spock and FEST. FindBugs joins the set of testing related plugins too.

All in all, Griffon will help you to keep the bar green and bugs in check.

Keep on Groovying!

About Andres Almiray

Andres Almiray

Andres is a Java/Groovy developer and Java Champion, with more than 11 years of experience in software design and development. He has been involved in web and desktop application developments since the early days of Java. He has also been teacher of computer science courses in the most prestigious education institute in Mexico. His current interests include Groovy and Swing. He is a true believer of open source and has participated in popular projects like Groovy, Griffon, JMatter and DbUnit, as well as starting his own projects (Json-lib, EZMorph, GraphicsBuilder, JideBuilder). Founding member and current project lead of the Griffon framework. He blogs periodically at http://jroller.com/aalmiray. You can find him on twitter too as @aalmiray. He likes to spend time with his beloved wife, Ixchel, when not hacking around.

More About Andres »

NFJS, the Magazine

December Issue Now Available
  • BDD and REST

    by Brian Sletten
  • Mocks and Stubs in Groovy Tests

    by Kenneth Kousen
  • Algorithms for Better Text Search Results

    by John Griffin
  • Knowns and Unknowns of Scrum and Agile

    by Brian Tarbox
Learn More »