You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Paul King (JIRA)" <ji...@apache.org> on 2018/08/06 09:56:00 UTC

[jira] [Commented] (GROOVY-7373) Interact Closures withing Groovy Trait methods are not recognized by the implementing class

    [ https://issues.apache.org/jira/browse/GROOVY-7373?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16569970#comment-16569970 ] 

Paul King commented on GROOVY-7373:
-----------------------------------

The example below works, so it isn't necessarily just Groovy here - we'd need to look at all the layers:
{code}
class MySpec extends GebLike implements DoStuff {
   def clickItemOnPage2() {
      interact {
         moveToElement('.myDiv')
         click()
      }
   }
   void testSomeStuff() {
      clickItemOnPage2()
      clickItemOnPage()
   }
}
class GebLike extends GroovyTestCase {
  def interact(Closure c) {
    c.delegate = this
    c.call()
  }
  def moveToElement(s) { println s }
  def click() { println 'clicking' }
}
trait DoStuff {
   def clickItemOnPage() {
      interact {
         moveToElement('.myDiv')
         click()
      }
   }
}
{code}

> Interact Closures withing Groovy Trait methods are not recognized by the implementing class
> -------------------------------------------------------------------------------------------
>
>                 Key: GROOVY-7373
>                 URL: https://issues.apache.org/jira/browse/GROOVY-7373
>             Project: Groovy
>          Issue Type: Bug
>          Components: groovy-runtime
>    Affects Versions: 2.4.0, 2.4.1, 2.4.2, 2.4.3
>         Environment: Win 7x64
> Ubuntu 14.04 (Gnome)
> Ubuntu 12.04
> Java: 1.8.0_40-b26
>            Reporter: Lee Davis
>            Priority: Major
>              Labels: closure, geb, groovy, interact, spock, traits
>
> Since moving to grails 2.5.0 (groovy 2.4.x) our functional tests (geb/spock) are failing when we try to run interact closures inside of a trait.  I'm not entirely sure who owns this one as there are three or four players groovy, grails, geb/spock, but groovy seemed like the most logical culprit.
> {code:Java|title=Example Usage}
> trait DoStuff {
>    def clickItemOnPage() {
>       interact {
>          moveToElement($('.myDiv'))
>          click()
>       }
>    }
> }
> class MySpec extends GebReportingSpec  implements DoStuff {
>    def clickItemOnPage2() {
>       interact {
>          moveToElement($('.myDiv'))
>          click()
>       }
>    }
>    def 'Test some stuff' { 
>       clickItemOnPage2() //Passes
>       clickItemOnPage() //Fails
>    }
> }
> {code}
> Error: groovy.lang.MissingMethodException: No signature of method: geb.navigator.NonEmptyNavigator.moveToElement()
> It really doesn't matter what you have in the interact closure anything fails...



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)