我最近开始在我的Java项目中使用spock framework用于BDD。 我注意到在spock规范中,可以在规范中定义一个特性和一个给定的when-then子句。例如:
MySpec extends Specification {
//As a User I want the system to behave in some way
def "it should provide feature 1"() {
given: "some state"
when : "some action"
then : "some symptom"
}
def "it should provide feature 2"() {
...
}
}
我缺少的是规范的用户故事部分,我在评论中添加的部分。
是否有可能以某种方式编写spock规范,该规范将以以下格式提供测试输出:
+As a User I want the system to behave in some way
+it should provide feature 1
-given some state
-when some action
-then some symptom
+it should provide feature 2
-given some state
-when some action
-then some symptom
这与ScalaTest输出结果的方式非常相似。
我基本上错过了顶级元素,这使我可以轻松地分组和显示功能。我想知道是否有这样的结构或者我不理解spock框架的真实性质。
答案 0 :(得分:3)
正在制作Spock 1.0的新业务报告将通过附加到规范类的@Narrative
注释来支持此功能。要获得第一印象,请参阅this sample spec和resulting report。