我有一些用Jbehave编写的场景,我想为1000+数据运行它。问题是我不能在'Examples‘中列出所有的数据项,因为首先,它是不可维护的,其次,我每天都从外部服务获得这个数据文件。
有没有一种方法可以编写一个可以从文件中获取数据的场景?
发布于 2014-11-29 00:08:29
参数可以从外部文件加载,
下面是一个示例的详细信息:http://jbehave.org/reference/stable/parametrised-scenarios.html
从外部资源加载参数
parameters表也可以从外部资源加载,无论是类路径资源还是URL。
Given a stock of <symbol> and a <threshold>
When the stock is traded at <price>
Then the alert status should be <status>
Examples:
org/jbehave/examples/trader/stories/trades.table 我们需要使解析器能够使用通过ExamplesTableFactory配置的相应资源加载器来查找资源:
new MostUsefulConfiguration()
.useStoryParser(new RegexStoryParser(
new ExamplesTableFactory(new LoadFromClasspath(this.getClass())))
)发布于 2015-03-23 18:42:14
我也有同样的要求,我认为下面将是可能的解决方案。
在场景开始执行之前,实现一个读取excel表格并准备testData.table的方法,在steps java文件中使用@BeforeScenario jbehave注释。
请参考此链接以实现从外部资源http://jbehave.org/reference/stable/parametrised-scenarios.html加载数据
@BeforeScenario
public void prepareTestData(String excelSheetPath) {
// java code to read given excelSheetPath and prepare a *.table
}https://stackoverflow.com/questions/27182925
复制相似问题