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
Post a Comment