[英]Quarkus unit-testing and properties
我有一個關於 Quarkus 測試的基本問題,我想執行命令./mvnw clean test
但我需要使用令牌來初始化應用程序。
我已經配置了application-test.properties
文件來存儲令牌:
discord.token=XYZ
因此,在我的代碼中,我期望能夠檢索discord.token
屬性的值:
@ConfigProperty(name = "discord.token")
private String token;
可能嗎? 如果沒有,我該怎么做?
謝謝
dev
配置文件由開發模式( ./mvnw quarkus:dev
)使用。 如果要為測試定義屬性,則需要使用test
配置文件。
您可以像以前那樣使用帶后綴的文件(但使用-test
后綴,即application-test.properties
)或使用%test.
在常規application.properties
中的屬性( %test.discord.token=XYZ
)前面。
有關詳細信息,請參閱https://quarkus.io/guides/config-reference#profiles 。
您可以改為將application.properties
文件放在src/test/resources
中,而不是將application-test.properties
放在src/main/resources
中
您也可以使用mvn -Dquarkus.config.locations=/tmp/foo.properties test
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.