Cucumber在eclipse文件夹中搜索不在当前项目文件夹中的.properties文件

时间:2015-05-14 09:29:05

标签: java eclipse cucumber-jvm

我能够使用其绝对路径读取文件,但是想使用相对路径。

Cucumber正在尝试在Eclipse目录中搜索我的资源文件,而不是在项目目录中搜索。

示例:

File f = new File("./src/values.properties");

input = new FileInputStream(f);
正在eclipse文件夹中搜索

values.properties文件,而不是在项目文件夹中搜索。

我们是否可以在cucumber-java中配置资源查找路径?

1 个答案:

答案 0 :(得分:0)

这是一个Eclipse问题,而不是一个黄瓜jvm问题。

在IDE中运行测试时,可以指定执行目录。在Eclipse Luna中,可以通过转到运行配置... 菜单来完成,对于黄瓜测试,进入 Arguments 选项卡,然后设置工作目录,选择“其他:”,然后键入要运行测试的目录。

或者,您可以将属性文件添加到IDE中的类路径中,然后使用以下命令加载它:

input = this.getClass().getClassLoader().getResourceAsStream("values.properties");