Griffon 0.9 sneak peek: testing upgrades - No Fluff Just Stuff

Griffon 0.9 sneak peek: testing upgrades

Posted by: Andres Almiray on July 6, 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!
Andres Almiray

About Andres Almiray

Andres is a Java/Groovy developer and a Java Champion with more than 20 years of experience in software design and development. He has been involved in web and desktop application development since the early days of Java. Andres is a true believer in open source and has participated on popular projects like Groovy, Griffon, and DbUnit, as well as starting his own projects (Json-lib, EZMorph, GraphicsBuilder, JideBuilder). Founding member of the Griffon framework and Hackergarten community event. https://ch.linkedin.com/in/aalmiray

Why Attend the NFJS Tour?

  • » Cutting-Edge Technologies
  • » Agile Practices
  • » Peer Exchange

Current Topics:

  • Languages on the JVM: Scala, Groovy, Clojure
  • Enterprise Java
  • Core Java, Java 8
  • Agility
  • Testing: Geb, Spock, Easyb
  • REST
  • NoSQL: MongoDB, Cassandra
  • Hadoop
  • Spring 4
  • Cloud
  • Automation Tools: Gradle, Git, Jenkins, Sonar
  • HTML5, CSS3, AngularJS, jQuery, Usability
  • Mobile Apps - iPhone and Android
  • More...
Learn More »