¿Cómo hacer que Cucumber deje que Spring inyecte classs definitivas en el paso?

Tengo una SpringBootApplication que ejecuta Cucumber (no como parte de las testings, sino como la aplicación principal.

Ocurre que hago esto en Kotlin, pero eso no debería importar.

Esta es la class de aplicación. El cuerpo de demo02 está copydo de algunas fonts de pepino y ha estado funcionando bien. Creo que no tiene nada de malo.

 package cutest import ... @CucumberOptions(tags = arrayOf("not @ignore"), features = arrayOf("sandbox/cutest/src/main/resources"), // features = arrayOf("src/main/resources"), format = arrayOf( "pretty", "html:target/site/cucumber/cucumber", "json:target/failsafe-reports/cucumber.json" ), strict = true) @SpringBootApplication open class CucumberApplication { @Bean open fun demo02() = CommandLineRunner { val cl : ClassLoader = javaClass.getClassLoader() val rl = MultiLoader(cl) val roFactory = RuntimeOptionsFactory(this.javaClass) val ro = roFactory.create() val classFinder : ClassFinder = ResourceLoaderClassFinder(rl, cl) val runtime : cucumber.runtime.Runtime = cucumber.runtime.Runtime(rl, classFinder, cl, ro) runtime.run() if(runtime.exitStatus().toInt() != 0) { throw RuntimeException("exit status: " + runtime.exitStatus()); } } } fun main(args: Array<String>) { SpringApplication.run(CucumberApplication::class.java, *args) } 

Luego tengo un file de características:

 Feature: Server is reachable Here I try to connect to my web server app @Basic Scenario: Can connect to REST service of the web server Given Cucumber is up and running Then I can connect to the REST web server 

Sus simples definiciones de pasos de trabajo, coinciden y pasan el paso. Given Cucumber is up and running :

 package cutest import cucumber.api.java.en.Given class SomeSteps { class SomeStepDefs { @Given(value = """^Cucumber is up and running$""") fun a() { assert(true) } } } 

Y ahora las definiciones de paso problemáticas. Tiene algunas annotations @Autowinetworking que parecen ser problemáticas:

 package cutest import ... class RestSteps { @Autowinetworking lateinit var ssh : PortForwardSshR @Value("\${cutest.url}") private val url = "http://example.com:8080/app/rest" @Given(value = """^I can connect to the REST web server$""") fun connectRest() { .... } } 

Cuando ejecuto esto obtengo el siguiente resultado:

 Feature: Cucumber is present Cucumber framework must be up and running @Basic Scenario: Cucumber works Given Cucumber is up and running Feature: Reseller Interface is reachable Here I try to ... @Basic Scenario: Can connect to REST service of the web server Given Cucumber is up and running Then I can connect to the REST web server kotlin.UninitializedPropertyAccessException: lateinit property ssh has not been initialized at cutest.RestSteps.connectRest(RestSteps.kt:47) at ✽.I can connect to the CAPs ... Failed scenarios: ... cutest/rest.feature:7 2 Scenarios (1 failed, 1 passed) 3 Steps (1 failed, 2 passed) 

Probablemente no haya mucha más información en el stacktrace, pero aquí está:

 kotlin.UninitializedPropertyAccessException: lateinit property ssh has not been initialized at cutest.RestSteps.connectRest(RestSteps.kt:47) at ✽.I can connect to the CAPs ResellerInterface(...cutest/rest.feature:9) 2017-11-07 13:46:08.974 INFO 11433 --- [ restartedMain] utoConfigurationReportLoggingInitializer : Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled. 2017-11-07 13:46:08.985 ERROR 11433 --- [ restartedMain] osboot.SpringApplication : Application startup failed java.lang.IllegalStateException: Failed to execute CommandLineRunner at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:735) [spring-boot-1.5.7.RELEASE.jar:1.5.7.RELEASE] at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:716) [spring-boot-1.5.7.RELEASE.jar:1.5.7.RELEASE] at org.springframework.boot.SpringApplication.afterRefresh(SpringApplication.java:703) [spring-boot-1.5.7.RELEASE.jar:1.5.7.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:304) [spring-boot-1.5.7.RELEASE.jar:1.5.7.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118) [spring-boot-1.5.7.RELEASE.jar:1.5.7.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107) [spring-boot-1.5.7.RELEASE.jar:1.5.7.RELEASE] at cutest.CucumberApplicationKt.main(CucumberApplication.kt:50) [classes/:na] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_144] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_144] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_144] at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_144] at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) [spring-boot-devtools-1.5.7.RELEASE.jar:1.5.7.RELEASE] Caused by: java.lang.RuntimeException: exit status: 1 at vc.capper.cutest.CucumberApplication$demo02$1.run(CucumberApplication.kt:44) ~[classes/:na] at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:732) [spring-boot-1.5.7.RELEASE.jar:1.5.7.RELEASE] ... 11 common frames omitted