简体   繁体   English

黄瓜在eclipse文件夹中而不是当前项目文件夹中搜索.properties文件

[英]Cucumber searches for .properties file in eclipse folder not in current project folder

I am able to read a file using its absolute path, but would like to use a relative path. 我能够使用其绝对路径读取文件,但想使用相对路径。

Cucumber is trying to search my resource files in Eclipse directory, not in project directory. 黄瓜正尝试在Eclipse目录中而不是项目目录中搜索我的资源文件。

example: 例:

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

input = new FileInputStream(f);

values.properties file is being searched in eclipse folder, not the in project folder. 在eclipse文件夹中而不是在项目文件夹中搜索values.properties文件。

Is there a way we can configure resource lookup path in cucumber-java ? 有没有一种方法可以在cucumber-java配置资源查找路径?

This is an Eclipse issue, rather than a cucumber-jvm one. 这是一个Eclipse问题,而不是cucumber-jvm问题。

When running your test in your IDE, you can specify the execution directory. 在IDE中运行测试时,可以指定执行目录。 In Eclipse Luna, this can be done by going to the Run Configurations... menu, and for your cucumber test, go into the Arguments tab, and set the Working directory by select “Other:” and typing in the directory in which you want to run the test. 在Eclipse Luna中,这可以通过转到“ 运行配置...”菜单来完成,对于黄瓜测试,请进入“ 参数”选项卡,并通过选择“其他:”并在其中键入您要输入的目录来设置工作目录 。要运行测试。

Alternatively, you can add the property file to your classpath in the IDE, and load it using: 或者,您可以将属性文件添加到IDE中的类路径,并使用以下命令加载它:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM