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

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

jsf - "PropertyNotWritableException: Illegal Syntax for Set Operation" error when setting value in bean -

laravel - Undefined property: Illuminate\Pagination\LengthAwarePaginator::$id (View: F:\project\resources\views\admin\carousels\index.blade.php) -