Spring Boot 1.4 issue with Cucumber-JVM -


when using spring boot 1.4 cucumber, @autowired beans not injected.

but when use plain junit tests, injected correctly! have looked here doesn't solve problem.

@springbootapplication @enableswagger2 @componentscan("org.services") public class servicesapplication {      public static void main(string[] args) {         springapplication.run(servicesapplication.class, args);     } }   @runwith(cucumber.class) public class userstest {  }  @runwith(springrunner.class) @springboottest public class userssteps {      @autowired     private usersservice _target;//null } 

edit: clarify, did view cucumber spring boot 1.4: dependencies not injected when using @springboottest , @runwith(springrunner.class) , put annotations

@runwith(springjunit4classrunner.class) @contextconfiguration(classes = application.class, loader = springapplicationcontextloader.class) 

didnt work

then put these annotations (as in answer)

@contextconfiguration @springboottest 

didnt work either

fixed

in pom.xml

 <dependency>             <groupid>info.cukes</groupid>             <artifactid>cucumber-spring</artifactid>             <version>${cucumber-junit.version}</version>             <scope>test</scope> </dependency> 

in userssteps class

    @springboottest     @contextconfiguration(classes = {servicesapplication.class})     @testpropertysource(locations = "classpath:test.properties")     public class userssteps  

Comments

Popular posts from this blog

amazon web services - S3 Pre-signed POST validate file type? -

c# - Check Keyboard Input Winforms -