[英]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.