【发布时间】:2021-03-05 19:45:48
【问题描述】:
我在项目的属性文件 (src/test/resources/application.properties) 中添加了以下环境变量:
#variables
limit=5
我想开发一个集成测试,但它总是出错,因为我的限制变量的值是 0 而不是 5(这是我在属性中设置的值)。我尝试使用@SpringBootTest 和@TestPropertySource 但我不成功,变量保持为零:
@RunWith(Cucumber.class)
@SpringBootTest(properties = {"limit=5"})
@CucumberOptions(features = { "classpath:project/feature/list" }, plugin = {"pretty" }, monochrome = true)
public class RunCucumberTestIT {
}
@RunWith(Cucumber.class)
@TestPropertySource(properties = {"limit=5"})
@CucumberOptions(features = { "classpath:project/feature/list" }, plugin = {"pretty" }, monochrome = true)
public class RunCucumberTestIT {
}
【问题讨论】:
-
嗯,
@SpringBootTest(properties = {"limit=5"})应该没问题,奇怪的是它不起作用。你也可以试试@TestPropertySource(locations = "classpath:application.properties")吗? -
你好,我试过这个:@TestPropertySource(locations = "classpath:application.properties", properties = {"limit = 5"}) 但变量保持为零
标签: java spring cucumber integration-testing