In my project I have a yaml file like this : service: url: http://10.10.100.09/service/ping
Currently I have setup my tests like this:
@RunWith(SpringRunner.class)
@SpringBootTest(properties =
{"service.url=http://10.10.100.09/service/ping"},webEnvironment =
SpringBootTest.WebEnvironment.RANDOM_PORT)
public abstract class BaseIntegration {
@Value("${local.server.port}")
private int serverPort;
@Before
public void setup() {
RestAssured.port = serverPort;
}
}
My test are extending the BaseIntegration class and the test code reside there.
Question: How can I read the url property directly from the config file and not hardcord it in the tests?
I did try using the @SpringBootApplication annotation but its giving error when I start my tests.
can you try
@SpringBootTest(properties = {"${service.url}"},webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
or
@SpringBootTest(properties = {"service.url"},webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.