Test scripts with cucumber and scala

I have a test environment written in Scala + cucumber. In step definition classes, it loads various dependencies in Spring beans, for example:

class TestSteps {
val b1 = dependency("bean_b1")

When("I do xxx") {() => 
 b1.doSomething()
}
}

I would like to activate the test run in various scenarios requiring initialization of the Spring context, and so bean_b1 will be initialized in different ways. I want to activate these scripts during the steps and write something like:

Given I set test scenario to "scenario1"
When I do xxx
Then I should receive ZZZ
Given I set test scenario to "no_network_available"
When I do xxx
Then I should receive ConnectException

This can be solved by running the entire test package with a different Spring context, but I need to follow the first steps with an available network, and then follow the last steps with the network disconnected.

, ( "..." ) bean Spring ( ). , def def, "val b1 = dependency (" b1_bean ")", , ( "b1_bean" ) - .

!

+3

All Articles