Assume i have following SoapApplication starter:
@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
so where is some properties in application.properties
In test I have:
public abstract class SoapTest {
protected static ConfigurableApplicationContext server;
protected static HttpClient client;
@BeforeAll
public static void setUp() {
server = SpringApplication.run(Application.class,"--a=1","--b=2");
server.start();
}
@AfterAll
public static void tearDown() {
server.stop();
}
}
So i'm not glad with "--a=1","--b=2"
I prefer to setup test.properties
I have tryed to make something like this:
@Configuration
@EnableAutoConfiguration
@PropertySource("file:testdata/test.properties")
public class TestConfig {
}
And SpringApplication.run(TestConfig.class, args);
But it still launches with application.properties.
How to do it well???
I think i cannot use suggestons from Override default Spring-Boot application.properties settings in Junit Test while it's not for Junit5 what i'm using (?).
Have done this way:
System.setProperty("spring.config.location", "file:testdata/test.properties"); server = SpringApplication.run(Application.class);
Is it correct? It works for me, but may be it's not much in best practice?