Ran*_*ize 2 groovy swing fest cucumber-jvm
我正在尝试使用Groovy(2.1.6)为Fest创建一个闭包匹配器,如下所示:
def matcherLabel = [ isMatching: { JLabel label -> /* do something */ } ] as GenericTypeMatcher<JLabel>
Run Code Online (Sandbox Code Playgroud)
GenericTypeMatcher是一个抽象类,只有一个方法可以实现(isMatching(T t))
但我得到这个错误:
org.codehaus.groovy.runtime.typehandling.GroovyCastException: Error casting map to org.fest.swing.core.GenericTypeMatcher, Reason: null
at org.codehaus.groovy.runtime.DefaultGroovyMethods.asType(DefaultGroovyMethods.java:7562)
Run Code Online (Sandbox Code Playgroud)
有可能我想做什么?
您的问题是GenericTypeMatcher
该类没有默认的零参数构造函数.将地图转换为类似的界面ComponentMatcher
.如果您不能使用接口,另一种方法是子类GenericTypeMatcher
并提供零参数构造函数.