在Cucumber中,我应该如何在步骤定义类之间传递变量。我正在尝试在Scala中实现。
我看到有人建议使用Guice或Picocontainer或任何其他DI框架。但是我还没有看到Scala的示例。
例如,在下面的示例中,我应该如何使用DI来传递变量?
Provider.scala,
我看到有人建议使用Guice或Picocontainer或任何其他DI框架。但是我还没有看到Scala的示例。
例如,在下面的示例中,我应该如何使用DI来传递变量?
Provider.scala,
class Provider extends ScalaDsl with EN with Matchers with WebBrowser {
......
When("""I click the Done button$""") {
val doneButton = getElement(By.id(providerConnectionButton))
doneButton.click()
}
Then("""a new object should be created successfully""") {
// Pass the provider ID created in this step to Consumer definition
}
}
Consumer.scala,
class Consumer extends ScalaDsl with EN with Matchers with WebBrowser {
......
When("""^I navigate to Consumer page$""") { () =>
// providerId is the id from Provider above
webDriver.navigate().to(s"${configureUrl}${providerId}")
}
}