0
我有一个使用黄瓜和硒测试设置的弹簧引导应用程序。我正在尝试创建一个用于运行我的黄瓜测试场景的UI包装器。我需要运行我正在使用cucumber.api.cli.Main.run方法的选定功能文件。 问题是我想通过我的application.yml文件选择属性,但我的步骤定义类无法选择属性。通过黄瓜步骤定义类拾取应用程序属性
这是我的代码看起来像 -
RunCukes类
@RunWith(Cucumber.class)
@CucumberOptions(features = {"classpath:features"},
plugin = { "pretty", "html:target/cucumber-html-report","json:target/cucumber.json" },
tags = {"[email protected]"})
public class RunCukesTest {
}
从其中黄瓜特征文件运行
@Service
public class SeleniumLogic {
@Autowired
RunCukesTest runCukes;
public byte runTest(String[] argv) throws IOException{
byte result = cucumber.api.cli.Main.run(argv,runCukes.getClass().getClassLoader());
return result;
}
}
的stepdefinition类的类
@Component
public class LoginTestSteps {
@Autowired
private LoginPage loginPage;
@Value("${host.name}")
private String HOST_NAME;
@Given("^User is on the login page$")
public void user_is_on_the_login_page() throws Throwable {
loginPage.load(HOST_NAME);
}
}
Application.yml
host:
name: abc.com
的HOST_NAME在LoginTestSteps类来为空。