【问题标题】:How to load a value from . properties file in Cucumber-jvm step class如何从 . Cucumber-jvm 步骤类中的属性文件
【发布时间】:2016-08-24 12:49:15
【问题描述】:

我写了一个黄瓜集成测试,它运行正常。

然后我想从 step.java 中获取一些类变量来从 .properties 值中获取它们的值

public class cucumberStepClass { 
    @Value("${value.from.propertiesfile}")
    private String variable
//rest of integration test
}

有谁知道我如何注入这些值以便我的测试可以使用它们?

【问题讨论】:

    标签: java spring testing integration cucumber-jvm


    【解决方案1】:

    您是否启用了与 spring 依赖注入的集成?您需要为此添加 cucumber-spring 依赖项。见https://docs.cucumber.io/cucumber/state/#spring

    【讨论】:

    【解决方案2】:

    将我的两分钱添加到第一个答案:记得用 @SpringBootTest@TestPropertySource("classpath:test.properties") 注释类。并且属性文件应该是.properties 扩展名或.xml.yml 无法加载。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-10-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多