Grails
  1. Grails
  2. GRAILS-9637

Grails Unit Tests using the new Annotation framework is slow

    Details

    • Type: Improvement Improvement
    • Status: Resolved
    • Priority: Critical Critical
    • Resolution: Fixed
    • Affects Version/s: 2.1.1, 2.2-RC2
    • Fix Version/s: 2.1.4, 2.2.1, 2.3-M1
    • Component/s: Testing
    • Labels:
      None

      Description

      Upgrading application from Grails 1.3.8 to 2.1.1 results in increased unit test time:

      Grails 1.3.8
      Total Tests: 2775
      Total Time: 303609ms (~5mins) (avg ~109.5ms/test)

      Grails 2.1.1
      Total Tests: 2306
      Total Time: 1134490ms (~19mins) (avg ~492ms/test)

      The Grails 2.1.1 application has a mixture of unit tests that use the annotation based framework or extend from GrailsUnitTestCase.

      Running just the old style tests that extend GrailsUnitTestCase:
      Total Tests: 550
      Total Time: ~55s (avg ~100ms/test)

      It appears that the @Mock annotation is traversing the entire domain graph (including classes that haven't been included in the Mock)

      This JIRA is being raised per the thread: http://grails.1312388.n4.nabble.com/Grails-2-0-4-unit-test-performance-td4637532.html

      1. test-launch-errors.log
        1.09 MB
        Youri Ackx

        Activity

        Hide
        John Engelman added a comment -

        @Aaron
        I'm working through one of our code bases now too (where we don't use BTD) and I'm creating some tickets along the way.
        GRAILS-9882 I already have and I'm trying to isolate an issue where it appears the order that you declare classes in @Mock matters. Not sure on this one yet.

        Show
        John Engelman added a comment - @Aaron I'm working through one of our code bases now too (where we don't use BTD) and I'm creating some tickets along the way. GRAILS-9882 I already have and I'm trying to isolate an issue where it appears the order that you declare classes in @Mock matters. Not sure on this one yet.
        Hide
        Aaron Long added a comment -

        Interesting. I have some situations where I'm getting "No signature of method: com.triu.location.Subsidiary.addToEmployees()" but I have both Subsidiary and Employee in the @Mock line. If I can work up a simple example I'll open a ticket.

        Show
        Aaron Long added a comment - Interesting. I have some situations where I'm getting "No signature of method: com.triu.location.Subsidiary.addToEmployees()" but I have both Subsidiary and Employee in the @Mock line. If I can work up a simple example I'll open a ticket.
        Hide
        Alvaro Sanchez-Mariscal added a comment -

        @Aaron, I faced a similar situation. In my case, both domains were in the @Build annotation, and the solution was to also add them to the @Mock one

        Show
        Alvaro Sanchez-Mariscal added a comment - @Aaron, I faced a similar situation. In my case, both domains were in the @Build annotation, and the solution was to also add them to the @Mock one
        Hide
        René Scheibe added a comment -

        Has this really been fixed? I haven't encountered a reduction in unit test execution time.
        250 tests ran about 15s in Grails 1.3.7 and but take about 50s in Grails 2.1.5.

        Show
        René Scheibe added a comment - Has this really been fixed? I haven't encountered a reduction in unit test execution time. 250 tests ran about 15s in Grails 1.3.7 and but take about 50s in Grails 2.1.5.
        Hide
        Graeme Rocher added a comment -

        It will never be as fast as 1.3.7 because 1.3.7 didn't include a complete mocking API for GORM and the testing APIs were very basic

        Show
        Graeme Rocher added a comment - It will never be as fast as 1.3.7 because 1.3.7 didn't include a complete mocking API for GORM and the testing APIs were very basic

          People

          • Assignee:
            Graeme Rocher
            Reporter:
            John Engelman
          • Votes:
            12 Vote for this issue
            Watchers:
            14 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development