Grails
  1. Grails
  2. GRAILS-8516

Spock unit test compilation failure with Grails 2.0

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0 final
    • Fix Version/s: 2.0.1
    • Component/s: None
    • Labels:
      None

      Description

      This issue is discussed here at Grails mailing list: http://markmail.org/message/4ogcho3v7o25ex4h

      The Spock unit test classes are failing to compile with Grails 2.0.0 with the following error:

      ClientSpec.groovy: 8: The return type of java.lang.Object mockDomain(java.lang.Class) in foo.Spec is incompatible with void mockDomain(java.lang.Class) in grails.plugin.spock.UnitSpec
      . At [-1:-1]
       @ line 8, column 1.
         class ClientSpec extends UnitSpec
      

      Groovy Verifier rejects these unit Spock test classes when it checks co-variant methods, because the following two definitions are defined inconsistently:

      1) DomainClassUnitTestMixin:

      def mockDomain(Class domainClassToMock, List domains = [])
      

      2) grails.plugin.spock.UnitSpec:

      void mockDomain(Class, List)
      

      I am not sure whether to see it is a Grails bug or as a Spock Grails plugin bug, but since even spock-core-0.5-groovy-1.7 defined it with return type "void", I am first trying it wth Grails.

        Activity

        Hide
        Roshan Dawrani added a comment -

        Attaching the sample app that reproduces the problem with Grails 2.0.0.

        Steps used were:

        All I did was:

        a) create the sample app
        b) add a dependency to plugin ':spock:0.6-SNAPSHOT'
        c) grails create-domain-class book
        d) grails test-app unit: -> this now fails to compile BookSpec due to the same error as reported above.

        Show
        Roshan Dawrani added a comment - Attaching the sample app that reproduces the problem with Grails 2.0.0. Steps used were: All I did was: a) create the sample app b) add a dependency to plugin ':spock:0.6-SNAPSHOT' c) grails create-domain-class book d) grails test-app unit: -> this now fails to compile BookSpec due to the same error as reported above.
        Hide
        Peter Ledbrook added a comment -

        Attached project works with Grails 2.0.1.

        Show
        Peter Ledbrook added a comment - Attached project works with Grails 2.0.1.

          People

          • Assignee:
            Unassigned
            Reporter:
            Roshan Dawrani
          • Votes:
            2 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:
              Last Reviewed:

              Development