Over the weekend I finally scrounged some mental space to write a small application to manage bookings for my badminton club. After debating between Ruby on Rails (RoR) and Grails, I decided on Grails.
As you might know Grails has very nice and expressive way of modeling the domain classes — arguably more elegant than RoR. And also that writing integration tests to experiment with the CRUD functionality makes writing a robust and testable model very simple.
So I wrote a bunch of integration tests as I was designing the domain classes. However, running the tests using grails test-app was proving to be very slow, and I mean really slow — 11 seconds to run tests on two domain classes.
Using grails test-app runs both unit and integration test. The actual time taken to run both the unit and integration tests wasn’t that much. It was the overall task of setting up the test environment that seemed to be taking a while.
So I experimented with a couple of options. You can chose to run only the unit or integration tests:
grails test-app -unit
grails test-app -integration
It is nicer in that one can run either unit or integration tests, but it still is quite time consuming as far as integration tests go.
To make a little more efficient, you can also just run integration tests on one class at a time:
grails test-app -integration className
This runs integration tests for only the class whose className is provided.
More information on this can be found in the Grails documentation.
Quicker, but still not fast enough to be called “agile”!
The final thing to try was to run the interactive Grails interactive shell:
This launches the Grails interactive shell in which you can issue various commands. So to test an app:
This takes a little while to setup the test environment etc., but once it is done, the next time you run test-app, Grails only takes the time to run actual tests, which is much faster and ‘agile’!