【发布时间】:2015-03-13 20:33:18
【问题描述】:
使用 jBehave,我想为参数化和非参数化步骤使用一种方法。 文档 (http://jbehave.org/reference/stable/parametrised-scenarios.html) 说我可以使用这样的别名:
@Given("a stock of symbol $symbol and a threshold of $threshold") // standalone
@Alias("a stock of <symbol> and a <threshold>") // examples table
public void aStock(@Named("symbol") String symbol, @Named("threshold") double threshold) {
// ...
}
但它不允许我使用完全相同的句子。我想做的是:
@Given("a stock of symbol $symbol and a threshold of $threshold") // standalone
@Alias("a stock of symbol <symbol> and a threshold of <threshold>") // examples table
public void aStock(@Named("symbol") String symbol, @Named("threshold") double threshold) {
// ...
}
但它会弹出一个警告:“Ambiguous step”。
我该怎么做?
最好只写:
@Given("a stock of symbol $symbol and a threshold of $threshold") // standalone
并将 $symbol 和 $threshold 替换为表中的示例。有没有 StoryTransformer 可以做到这一点?
【问题讨论】: