In my application I initialize a property before spring application startup as follows:
MapLookup.setMainArguments(new String[] {"logging.profile", profile}); //from args
SpringApplication.run(source, args);
(just for reference: it is used for log4j2
logging, which must be set before spring starts to initialize).
Now I want to run an @IntegrationTest
, but use the same logging configuration. Obviously I cannot use the code above, as a JUnit
test is not executed using SpringApplication.run
.
So, how could I initialize code before a @RunWith(SpringJUnit4ClassRunner.class)
starts?
Note: BeforeClass
does not work as this is executed after spring context startup.