你如何使用 concordion:run 参数?

How do you use concordion:run with parameters?

我想 运行 使用参数的 Concordion 规范。我想做的是使用 concordion:run 执行规范。 little research 指出存在 concordion:params 属性,但我找不到任何文档或示例。

我不确定这两个命令如何组合在一起; params 元素应该嵌套在 run 元素内部还是外部?要填写的值是多少 concordion:params="?" 我在哪里指定参数值本身——在 concordion:set 调用中?

concordion:params 是要在与 concordion:run 属性相同的元素上使用的属性。

例如,在MyIndex.html中:

<a concordion:run="concordion" concordion:params="foo=5" href="MySpec.html">My Spec</a>

与夹具 class:

@RunWith(ConcordionRunner.class)
@FullOGNL
public class MyIndex {
    public void setFoo(Integer foo) {
        System.out.println("foo = " + foo);
    }
}

请注意,@FullOGNL 属性是允许表达式中语法 foo=5 所必需的,否则是不允许的。

注意: Tim Wright pointed out 对这种方法有疑问:

The issue I see is that the same specification might be run from two different specifications (or run twice from a single specification) with different parameters as well as from jUnit with no parameters. As we only create one HTML file, the behaviour might not be what the user expects. It also means that using concordion:run will create a different specification from running the spec directly as a jUnit test - which is something we've tried hard to avoid.

The current behaviour (with the concordion run cache) is that the first one to be called will create the HTML file - and the second one will return a run results from the cache thus ignoring the parameter.

这可能意味着我们弃用 concordion:params 并在 2.0 中将其删除。