java - 与黄瓜一起使用宁静时无法读取应用程序 yaml
问题描述
我有一个 runner 类,它作为入口点并使用CucumberWithSerenity.class
.
@RunWith(CucumberWithSerenity.class)
@CucumberOptions(features = "src/test/resources")
public class CucumberIntegrationTest {
}
我创建了一个供 stepdef 类使用的基类,
这是我的 stepdef/glue。
public class StepDefs extends SpringIntegrationTest {
@Value("${config.value}")
private String configValue;
@When("^the client calls /version$")
public void the_client_issues_GET_version() throws Throwable {
String s = configValue;
}
@Then("^the client receives status code of (\\d+)$")
public void the_client_receives_status_code_of(int statusCode) throws Throwable {
String s = configValue;
}
@And("^the client receives server version (.+)$")
public void the_client_receives_server_version_body(String version) throws Throwable {
String s = configValue;
}
}
这是步骤的功能文件。
Feature: the version can be retrieved
Scenario: client makes call to GET /version
When the client calls /version
Then the client receives status code of 200
And the client receives server version 1.0
我的资源文件夹中application.yml
也application-stg.yml
有 configvalue。
config:
value: SOME_VALUE
但是,我无法读取读取配置,使用以下,它始终为空。
@Value("${config.value}")
private String configValue;
我错过了什么?
解决方案
推荐阅读
- python - 在 xarray 或 Numpy 中计算卷积类型的积分
- python - 带 aiohttp TestClient 的多部分文件上传导致第二次请求出现“无效的 HTTP 方法”错误
- git - 即使对于零值,如何强制 diffstat 始终显示插入、删除和修改的数量?
- flutter - 在主屏幕中使用动画容器时,是否有另一种方法可以在启动屏幕过去后移动到主屏幕?
- python - GoldenLayout(ipygoldenlayout):如何以编程方式更改选项卡?
- javascript - 拆分字符串时如何在对象键中添加“/*!*/”?
- mongodb - 如何在两个集合中更新 mongodb
- sql-server - 如何从一组数据中返回空值以在 SQL 中显示
- flutter - 如何在颤动中从谷歌地图中获取取消选择标记的回调?
- docker - 在端口 80 上运行的 docker 容器的 Nginx 反向代理