【发布时间】:2020-07-30 17:41:49
【问题描述】:
在我的应用程序中,我有两个功能文件:
processing.feature
copy.feature
对于这些,我有两个步骤定义文件:
加工特点:
public class ProcessingFeature {
@Qualifier("moverA")
@Autowired
private IFileMover mover;
@Given("check file is available")
public void load() {
}
@When("the file is there at the location")
public void moveFile() {
output= mover.move(info);
}
}
复制功能:
public class CopyFeature {
@Qualifier("moverB")
@Autowired
private IFileMover mover;
@Given("check file is available")
public void load() {
}
@When("the file is there at the location")
public void moveFile() {
output= mover.move(info);
}
}
在我的两个功能文件中,我将check file is available 作为@Given 步骤运行。我的第一个问题是,它们是位于两个步骤 def 文件中的相同步骤定义。什么是正确的模式,所以这段代码不会重复,两个功能都可以使用它?
其次,两个功能都运行the file is there at the location,但一个使用MoverA,另一个使用MoverB。但这个想法保持不变。同样,我不喜欢重复,所以我可以通过一些抽象如何最好地重用?
当然我得到了cucumber.runtime.DuplicateStepDefinitionException: Duplicate step definitions 异常,但我很想知道解决这类问题的正确模式是什么
【问题讨论】:
标签: java spring cucumber bdd gherkin