I just started to use ScalaTest and I want to do some initialisation before my feature test.
my test looks something like this:
class InvoiceTests extends FeatureSpec with GivenWhenThen with ShouldMatchers {
feature("Traffic Light Test") {
//this is where I want to initialise
scenario("test 1") {
val something = Invoice(bla bla bla)
Given("A connection to the system")
login.isConnected shouldBe true
When("an invoice that was uploaded to the system")
val invoiceAction = new InvoiceActions(driver,conf.getString("web.environment"))
invoiceAction.uploadInvoice(something)
And("the invoice is processed with information to be ready to reclaim")
invoiceAction.fillInvoice(something)
Then("Inovice status should be ready to reclaim")
invoiceAction shouldBe 'isReadyToReclaim
}
scenario("test 2") {
val something = Invoice(bla bla bla)
Given("A connection to the system")
login.isConnected shouldBe true
When("an invoice that was uploaded to the system")
val invoiceAction = new InvoiceActions(driver,conf.getString("web.environment"))
invoiceAction.uploadInvoice(something)
And("the invoice is processed with information to be ready to reclaim")
invoiceAction.fillInvoice(something)
Then("Inovice status should be ready to reclaim")
invoiceAction shouldBe 'isReadyToReclaim
}
}
So I have 2 scenarios here, test 1 and test 2, but I want to for them to have the same driver object and to login once before the whole feature starts. so where do I put this initializations code:
val driver = new FirefoxDriver()
val conf = ConfigFactory.load()
val loginObj: LoginActions = new LoginActions(driver, conf.getString("web.environment"))
loginObj.login(conf.getString("user.nir.username"),conf.getString("user.nir.pass"))
cause I cannot put it between the feature and the first scenario.
thanks!