-1

I am new to cucumber and I am automating a scenario. Initially I kept my features files in the path C:\Users\test\eclipse-workspace\Automation\src\test\resources\featureFile. Then I moved the feature files to a different path (C:\Users\test\eclipse-workspace\Automation\src\test\com\test]automation\features). I have updated the same in CucumberOptions as shown below.

@CucumberOptions(features = {
        "src/test/java/com/test/automation/features/CO_Self_Service_Home_Page_Personalizations.feature" }, glue = {
                "src/test/java/com/oracle/peoplesoft/HCM/StepDefinitions" })

But when I try to run the feature, I am getting the below exception stating the feature file is not found. Here the path shown in the exception is the old path. I am not sure from where it is fetched as I have updated the new path in Cucumber options. Can you please help me understand the cause of this issue.

Exception in thread "main" java.lang.IllegalArgumentException: Not a file or directory: C:\Users\test\eclipse-workspace\Automation\src\test\resources\featureFile\Self_Service_Home_Page_Personalizations.feature 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.loadFromFeaturePath(CucumberFeature.java:103) at cucumber.runtime.model.CucumberFeature.load(CucumberFeature.java:54) at cucumber.runtime.model.CucumberFeature.load(CucumberFeature.java:34) at cucumber.runtime.RuntimeOptions.cucumberFeatures(RuntimeOptions.java:235) at cucumber.runtime.Runtime.run(Runtime.java:110) at cucumber.api.cli.Main.run(Main.java:36) at cucumber.api.cli.Main.main(Main.java:18)

Murthi
  • 5,299
  • 1
  • 10
  • 15
  • There is an extra 'java' in the value set to features. The 'java' part is missing in the part where you mention the new folder hierarchy. – Grasshopper Dec 22 '17 at 13:14
  • See the last point - Possible duplicate of [Cannot instantiate test steps class](https://stackoverflow.com/questions/47925875/cannot-instantiate-test-steps-class/47927644#47927644) – undetected Selenium Dec 23 '17 at 11:08

1 Answers1

0

There are a couple of points you need to take care as follows :

  • As per Best Practices cerate the directory features which will contain the featurefile(s) strictly through your IDE only (not through other softwares Notepad or Textpad or SubLime3) as per the image below (New -> File) :

CO_Self_Service_Home_Page_Personalizations

  • Create the featurefile i.e. CO_Self_Service_Home_Page_Personalizations.feature within features directory strictly through your IDE only.
  • Keep your Project Structure simple by placing the directory containing the featurefile(s) just under Project Workspace. For Featurefiles Cucumber works with directory names. So create the features directory just under your project space Automation (same hierarchy as src). So the location of the Self_Service_Home_Page_Personalizations.feature will be :

    C:\Users\test\eclipse-workspace\Automation\features\Self_Service_Home_Page_Personalizations.feature
    
  • Again, as in your Class file containing @CucumberOptions you have mentioned glue = {"StepDefinitions" } ensure that the Class file containing @CucumberOptions must be in the similar hierarchy as the figure below :

Cucumber_Project_Structure

  • So your CucumberOptions will be as follows :

    @CucumberOptions(features = {"features" }, glue = {"StepDefinitions" })
    
  • Execute your Test

Note : Do not move/copy feature file(s)/directory(ies). Delete the unwanted and create a new one through your IDE only.

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352