Question

I've a test framework written in Scala+Cucumber. In the step definition classes, it loads various dependencies to Spring beans like:

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

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

I'd like to activate run the test in various scenarios that require the Spring context to be initialized differently and so bean_b1 would be initialized differently. I want to activate these scenarios during the steps execution 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 could be resolved by launching the whole test suite with a different spring context but I need to execute the first steps with network available and then last steps with network down.

I was thinking that when dependency("...") is executed to resolve to a bean in a different Spring context(loaded based on scenario). But how to make the tests work since I have a lot of step def classes that use the "val b1 = dependency("b1_bean")" and those will remain even static no matter if dependency("b1_bean") will now return something else.

Thanks!

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top