黄瓜:java.lang.IllegalArgumentException:不是文件或目录:G:\Codebase\MavenCucumber\--plugin
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/39319947/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Cucumber : java.lang.IllegalArgumentException: Not a file or directory: G:\Codebase\MavenCucumber\--plugin
提问by Avijit
Using Maven whenever I am trying run my feature file in eclipse I am getting below error:
每当我尝试在 Eclipse 中运行我的功能文件时使用 Maven,我都会收到以下错误:
Exception in thread "main" java.lang.IllegalArgumentException: Not a file or directory: G:\Codebase\MavenCucumber--plugin at cucumber.runtime.io.FileResourceIterator$FileIterator.(FileResourceIterator.java:54) at cucumber.runtime.io.FileResourceIterator.(FileResourceIterator.java:20) at cucumber.runtime.io.FileResourceIterable.iterator(FileResourceIterable.java:19) at cucumber.runtime.model.CucumberFeature.load(CucumberFeature.java:38) at cucumber.runtime.RuntimeOptions.cucumberFeatures(RuntimeOptions.java:117) at cucumber.runtime.Runtime.run(Runtime.java:92) at cucumber.api.cli.Main.run(Main.java:20) at cucumber.api.cli.Main.main(Main.java:12)
线程“main”中的异常 java.lang.IllegalArgumentException:不是文件或目录:G:\Codebase\MavenCucumber--cucumber.runtime.io.FileResourceIterator$FileIterator.(FileResourceIterator.java:54) 中的 plugin.runtime。 io.FileResourceIterator.(FileResourceIterator.java:20) 在cucumber.runtime.io.FileResourceIterable.iterator(FileResourceIterable.java:19) 在cucumber.runtime.model.CucumberFeature.load(CucumberFeature.java:38) 在cucumber.runtime。 RuntimeOptions.cucumberFeatures(RuntimeOptions.java:117) 在cucumber.runtime.Runtime.run(Runtime.java:92) 在cucumber.api.cli.Main.run(Main.java:20) 在cucumber.api.cli.Main .main(Main.java:12)
The above image is the structure of my project and feature file contains below code-
上图是我项目的结构,功能文件包含以下代码-
@tag
Feature: Proof of Concept
@tag1
Scenario: This is my first test Scenerio
Given This is my first step
When This is my second step
Then This is my third step
回答by Avijit
I was using 1.1.2 version jar for cucumber-java,cucumber-junit,cucumber-picocontainer. Because of that I got above mentioned error.
我使用 1.1.2 版本的 jar 来处理黄瓜 java、黄瓜 junit、黄瓜 picocontainer。因此,我得到了上述错误。
Now I am using 1.2.2 version jar and it is working absolutely fine with this version.
现在我使用的是 1.2.2 版本的 jar,它在这个版本上运行得非常好。
回答by Lakshay Sharma
This error clearly says that "Not a file or directory" which means the path is not correct. There can be multiple cause for this.
此错误清楚地表明“不是文件或目录”,这意味着路径不正确。这可能有多种原因。
One is upgrading the Cucumple libraries to latest version, which worked in your case.
一种是将 Cucumple 库升级到最新版本,这对您的情况有效。
Second is the placement of the feature files. I assume that the feature files can be at the two places only:
其次是特征文件的放置。我假设功能文件只能在两个地方:
- With in the src folder or src sub-folders.
- Outside the src folder, which means you keep your features files in some folder in the project but outside src package.
- 在 src 文件夹或 src 子文件夹中。
- 在 src 文件夹之外,这意味着您将功能文件保存在项目的某个文件夹中,但在 src 包之外。
In the first case you should specify your CucumberOptions as below:
在第一种情况下,您应该指定 CucumberOptions 如下:
@RunWith(Cucumber.class)
@CucumberOptions(
features = "src/somefolder/Feature"
In the second case:
在第二种情况下:
@RunWith(Cucumber.class)
@CucumberOptions(
features = "Feature")
Look at the example of second case here http://toolsqa.com/cucumber/first-cucumber-selenium-java-test/
在这里查看第二种情况的示例http://toolsqa.com/cucumber/first-cucumber-selenium-java-test/
回答by Chetan
below Cucumber Options format worked for me
以下 Cucumber Options 格式对我有用
src\main\java\com.qa.features
com.qa.stepDefinition
@RunWith(Cucumber.class)
@CucumberOptions(
features = "src\main\java\com\qa\features"
,glue={"com/qa/stepDefinition"}
,format={"pretty","html:test-output"}
}
回答by user10674922
Actually, The issue happened with me because the feature file name was written in upper case. When I changed it to a lower case the issue was resolved.
实际上,这个问题发生在我身上,因为特征文件名是大写的。当我把它改成小写时,问题就解决了。
回答by William
try
尝试
mvn test -Dcucumber.options="--tags @TagName"