2016-09-04 26 views
0

使用Maven,每當我在Eclipse中我得到下面的錯誤嘗試運行我的特點文件:黃瓜:java.lang.IllegalArgumentException異常:不是一個文件或目錄:G:代碼庫 MavenCucumber - 插件

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)

enter image description here

上面的影像是我的項目的結構和功能,文件包含以下代碼 -

@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 

回答

4

我用的是1.1.2版本的jar黃瓜的Java,黃瓜菊NIT,黃瓜,PicoContainer的。正因爲如此,我得到了上面提到的錯誤。

現在我使用的是1.2.2版本的jar,它在這個版本中工作得很好。

+0

感謝的例子。有一些問題,你的解決方案也適用於我。 – chucknor

1

這個錯誤清楚地表明「不是文件或目錄」,這意味着路徑不正確。這可能有多種原因。

一個是將Cucumple庫升級到最新版本,在你的情況下工作。

其次是特徵文件的放置。我認爲功能文件只能在兩個位置:

  1. With在src文件夾或src子文件夾中。
  2. 在src文件夾之外,這意味着您將功能文件保存在項目中的某個文件夾中,但是在src包之外。

在第一種情況下,你應該如下指定CucumberOptions:

@RunWith(Cucumber.class) 
@CucumberOptions(
     features = "src/somefolder/Feature" 

在第二種情況:

@RunWith(Cucumber.class) 
@CucumberOptions(
     features = "Feature") 

看看第二種情況在這裏http://toolsqa.com/cucumber/first-cucumber-selenium-java-test/

相關問題