[英]How to load a value from . properties file in Cucumber-jvm step class
我已經寫了一個黃瓜集成測試,它運行正常。
然后我想從step.java中獲取一些類變量,以從.properties值中獲取它們的值
public class cucumberStepClass {
@Value("${value.from.propertiesfile}")
private String variable
//rest of integration test
}
有誰知道如何注入這些值,以便我的測試可以使用它們?
您是否啟用了與彈簧依賴注入的集成? 你需要添加cucumber-spring
依賴性。 請參閱https://docs.cucumber.io/cucumber/state/#spring
將我的兩分錢加到第一個答案:記得用@SpringBootTest
和@TestPropertySource("classpath:test.properties")
注釋該類。 屬性文件應該是.properties
擴展名或.xml
。 .yml
無法加載。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.