我最近开始在我的 Java 项目中使用用于 BDD的spock 框架。我注意到在 spock 规范中,可以在规范中定义一个特性和一个 given-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 框架的真实性质。