How to speed up grails test execution

前端 未结 7 1393
孤独总比滥情好
孤独总比滥情好 2020-12-12 21:31

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 exec

相关标签:
7条回答
  • 2020-12-12 22:05

    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.

    0 讨论(0)
  • 2020-12-12 22:07

    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

    0 讨论(0)
  • 2020-12-12 22:11

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

    0 讨论(0)
  • 2020-12-12 22:11

    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.

    0 讨论(0)
  • 2020-12-12 22:17

    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.

    0 讨论(0)
  • 2020-12-12 22:19

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

    0 讨论(0)
提交回复
热议问题