Avijit
Avijit

Reputation: 1800

Cucumber : java.lang.IllegalArgumentException: Not a file or directory: G:\Codebase\MavenCucumber\--plugin

Using Maven whenever I am trying run my feature file in eclipse I am getting below error:

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

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

Upvotes: 3

Views: 35625

Answers (7)

Avinash Khadsan
Avinash Khadsan

Reputation: 497

Just add feature & stepDefination package like below into your TestRunner Java class

@CucumberOptions(features = "src/test/java/feature",
glue = "src/test/java/stepDefination", monochrome = true)
public class TestNGRunner extends AbstractTestNGCucumberTests{


}

Upvotes: 0

Supriya Bashetty
Supriya Bashetty

Reputation: 1

The issue was resolved by creating a separate folder i.e. 'Feature' under a project,instead of keeping the feature file in sub folder of a project.

Upvotes: -1

William
William

Reputation: 539

try

mvn test -Dcucumber.options="--tags @TagName"

Upvotes: 0

user10674922
user10674922

Reputation: 11

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.

Upvotes: 1

AchillesCK
AchillesCK

Reputation: 5

below Cucumber Options format worked for me

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"}
}

Upvotes: 0

Lakshay Sharma
Lakshay Sharma

Reputation: 101

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.

Second is the placement of the feature files. I assume that the feature files can be at the two places only:

  1. With in the src folder or src sub-folders.
  2. Outside the src folder, which means you keep your features files in some folder in the project but outside src package.

In the first case you should specify your CucumberOptions as below:

@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/

Upvotes: 3

Avijit
Avijit

Reputation: 1800

I was using 1.1.2 version jar for cucumber-java,cucumber-junit,cucumber-picocontainer. Because of that I got above mentioned error.

Now I am using 1.2.2 version jar and it is working absolutely fine with this version.

Upvotes: 6

Related Questions