在 Eclipse 中为 Spock 的 @Shared 注释获取错误
Getting error in eclipse for spock's @Shared annotation
作为尝试,我在eclipse中创建了一个简单的groovy class,并编写了一个简单的spock测试方法。
我用 @Shared
注释创建了一个对象,eclipse 抱怨如下:
Multiple markers at this line
- Groovy:unable to resolve class Shared , unable to find class
for annotation
- Groovy:class Shared is not an annotation in @Shared
我用谷歌搜索了一下,但没有找到解决方案。有谁知道为什么会发生此错误?下面是示例代码:
class SimpleSpockTestExampleSpec extends Specification {
@Shared
MyObject obj;
def "length of Spock's and his friends' names"()
{
expect:"Replaces when-then block"
name.size() == length
where:
name << ["zzzzz","xxx","yyy"]
length << [5,6,7]
}
}
请忽略图片中的行号。
您似乎没有导入合适的包。代码中是否有如下语句:
import spock.lang.Shared
?
作为尝试,我在eclipse中创建了一个简单的groovy class,并编写了一个简单的spock测试方法。
我用 @Shared
注释创建了一个对象,eclipse 抱怨如下:
Multiple markers at this line
- Groovy:unable to resolve class Shared , unable to find class
for annotation
- Groovy:class Shared is not an annotation in @Shared
我用谷歌搜索了一下,但没有找到解决方案。有谁知道为什么会发生此错误?下面是示例代码:
class SimpleSpockTestExampleSpec extends Specification {
@Shared
MyObject obj;
def "length of Spock's and his friends' names"()
{
expect:"Replaces when-then block"
name.size() == length
where:
name << ["zzzzz","xxx","yyy"]
length << [5,6,7]
}
}
请忽略图片中的行号。
您似乎没有导入合适的包。代码中是否有如下语句:
import spock.lang.Shared
?