I need to test my Spring application code by creating a Cucumber integration test. I am using SpringApplicationBuilder to start up my application before the actual logic is triggered and am using the following syntax to do so:-
application = new SpringApplicationBuilder()
.parent(new Object[]{"classpath:file1.xml", "classpath:file2.xml"})
.profiles("abc")
.properties("name:value") [It has 5/6 (name:value) pairs here]*
.showBanner(false)
.logStartupInfo(true)
.headless(true)
.application()
.run();
My Spring application starts up correctly. However, it does not get the values for the property (name, value) pairs that I am passing to the SpringApplicationBuilder(). I have tried the following to set them :-
None of these options are working, so when the application starts up and the code tries to access certain System Property values, it breaks.
Any ideas how this could be fixed.. All the help is greatly appreciated!
The properties you configure on SpringApplicationBuilder are made available in your application's Environment, not as system properties. If your code's expecting system properties then you should set them using System.setProperty(key, value) or as -D arguments when you launch the JVM
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With