25

While developing a Grails 1.0.5 app I'm appalled at how slow the grails test-app command is. Even though the actual tests take just ~10 seconds, the whole execution adds up to

real 1m26.953s user 0m53.955s sys 0m1.860s

This includes grails bootstrapping, loading plugins, compiling all the code, etc.

Any hints on how to speed up the grails test-app execution would be greatly appreciated.

Carl Veazey
  • 18,392
  • 8
  • 66
  • 81
Robert Munteanu
  • 67,031
  • 36
  • 206
  • 278

7 Answers7

35

You can use interactive mode to speed up your test runs.

Just run

grails interactive

Then type

test-app

The first time will be the same as usual but each time after that will be dramatically faster. There are currently some issues with interactive mode (like running out of memory after a few runs) but I still find it worth it.

rnielsen
  • 700
  • 1
  • 5
  • 11
  • 6
    I just recommend setting your permgen space more generously or you'll run out after a dozen cycles. This is what I use: -XX:PermSize=64m -XX:MaxPermSize=512m – Kuukage Aug 09 '09 at 01:42
  • 1
    We run our grails project via Maven, in this case the first command is: mvn grails:exec -Dcommand="interactive". – David Padbury Sep 27 '10 at 15:18
  • 3
    Also, after the first run you can rerun the test-app command by just pressing Enter. – David Padbury Sep 27 '10 at 15:20
  • Thanks for that, really helped me out. Is there any way to combine this with a plugin that watches your code and does an autobuild? This is how I develop on the front-end and it really speeds up my dev time. – Brian F Mar 30 '15 at 02:30
6

There aren't any hard and fast rules for speeding it up, and the performance issues that you're seeing might be specific to your app.

If your bootstrapping is taking ~75 seconds, that sounds pretty long. I'd take a close look at whatever you have in your Bootstrap.groovy file to see if that can be slimmed down.

Do you have any extra plugins that you might not need (or that could have a major performance penalty)?

This might not be a possibility for you right now, but the speed improvements in grails 1.1.1/groovy 1.6.3 over grails 1.0.5/groovy 1.5.7 are fairly significant.

Another thing that really helps me when testing, is to specify only integration tests or only unit tests if I'm workiing on one or the other:

grails test-app -unit

grails test-app -integration

You can also specify a particular test class (without the "Tests" prefix), to run a single test which can really help with TDD (ex for "MyServiceTests" integration):

grails test-app -integration MyService

In grails 1.1.1, bootstrapping with 5 plugins and ~40 domain classes takes me less than 20 seconds.

Ted Naleid
  • 26,511
  • 10
  • 70
  • 81
1

You can choose to run unit and integration tests in parallel as well - see this article

Sudhir N
  • 4,008
  • 1
  • 22
  • 32
1

grails now comes with http://grails.org/plugin/testing installed. this mocks the domain stuff, so you can do some testing of domain classes as unit tests. they run pretty fast.

Jay Prall
  • 5,295
  • 5
  • 49
  • 79
Ray Tayek
  • 9,841
  • 8
  • 50
  • 90
1

Increasing the java memory/JVM options can definitely speed things up. The amount of memory you can give depends on your equipment.

If you are running grails from the command line, set the GRAILS_OPTS environment variable. Add something like this to ~/.bash_profile

export GRAILS_OPTS="-Xms3000M -Xmx3000M -XX:PermSize=256m -XX:MaxPermSize=512m"

If you use GGTS(Eclipse) you'll need to add this to the VM arguments of the run configuration. GGTS vm args

There are also a few JVM settings that can be modified to increase the speed:

-XX:+UseCodeCacheFlushing 
-XX:MaxInlineLevel=15  
-noverify  (turns off class validation) 
Jay Prall
  • 5,295
  • 5
  • 49
  • 79
1

Please see my answer here. A plugin relying on a poorly defined maven artifact can cause grails to go and look every time for a newer version.

Grails very slow to resolve certain dependencies

Community
  • 1
  • 1
Peter
  • 29,498
  • 21
  • 89
  • 122
1

If you're still using Groovy 1.5.x you could probably of shave a few seconds by upgrading to Groovy 1.6

Kimble
  • 7,295
  • 4
  • 54
  • 77
  • Thanks for the answer. I'm not going to make that move since I'm uncertain of how Grails 1.0.x will work with 1.6.x and 1.5.x is the bundled one. – Robert Munteanu Jun 03 '09 at 14:36