java - Unable to inject AutoWired Enviroment when using Spring Boot 1.4 testing annotations -


i running integration tests on spring boot application using cucumber , in step definitions, code had been bootstrapping spring boot app using this:

@runwith(springjunit4classrunner.class) @contextconfiguration(classes = application.class, loader = springapplicationcontextloader.class) @webappconfiguration @integrationtest @slf4j public class creditcardstepdefs {  ....  } 

now, i'm trying refactor code make use of simplified annotations in spring boot 1.4 , same piece of code looks now:

@runwith(springrunner.class) @springboottest(webenvironment = webenvironment.defined_port) @slf4j public class creditcardstepdefs {  ...  } 

however, i'm facing problems in picking environment variables in particular piece of code:

@autowired private environment env;  @before("@run, @post") public void setup() {     this.host = env.getproperty("test.url") + env.getproperty("server.contextpath");     this.results = new hashmap<>();     this.paramkeylist = new arraylist<>();     this.retry = false;     this.ispassed = true; } 

when run test, "env.getproperty()" throw npe. seems @autowired environment doesn't work anymore using annotations above. need in order environment injected context?


Comments

Popular posts from this blog

php - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -