I'm new to cucumber. I have created a cucumber project but cannot seem to run the project. Every time I do, I get an error: java.lang.IllegalArgumentException: Not a file or directory:
Here is how my project is set up:
|-src
|-test
|-java
|-com
|-project
|-cucumber
-Tester.java
-MyFeature.feature
-TestRunner.java
here's what is in Tester.java
public class Tester {
@Given("This is test one")
public void TestOne(){
System.out.println("@Given -- This is test one");
}
@When("This is test two")
public void TeestTwo(){
System.out.println("@When -- This is test two");
}
@Then("This is test three")
public void TestThree(){
System.out.println("@Then -- This is test three");
}
@And("This is test four")
public void TestFour(){
System.out.println("@And -- This is test four");
}
@But("This is test five")
public void TestFive(){
System.out.println("@But -- This is test five");
}
}
And here's what is in tester.feature:
Feature: About Testers
In order to get a high paid job
As a Tester
I want to learn Automation
Scenario: I am a Manual Tester
Given This is test one
When This is test two
Then This is test three
And This is test four
But This is test five
And here's what is in testRunner.java:
@RunWith(Cucumber.class)
@CucumberOptions(
format = {"pretty", "json:target/cucumber.json"},
features = {"/src/test/java/com/project/cucumber"}
)
public class testRunner {}
This is the error i am getting:
java.lang.IllegalArgumentException: Not a file or directory: /src/test/java/com/project/cucumber/cucumber
at cucumber.runtime.io.FileResourceIterator$FileIterator.<init>(FileResourceIterator.java:54)
at cucumber.runtime.io.FileResourceIterator.<init>(FileResourceIterator.java:20)
at cucumber.runtime.io.FileResourceIterable.iterator(FileResourceIterable.java:19)
at cucumber.runtime.model.CucumberFeature.loadFromFeaturePath(CucumberFeature.java:101)
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:201)
at cucumber.api.junit.Cucumber.<init>(Cucumber.java:60)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:104)
at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:86)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:26)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
at org.junit.runners.model.RunnerBuilder.runners(RunnerBuilder.java:101)
at org.junit.runners.model.RunnerBuilder.runners(RunnerBuilder.java:87)
at com.intellij.junit4.JUnit46ClassesRequestBuilder.collectWrappedRunners(JUnit46ClassesRequestBuilder.java:90)
at com.intellij.junit4.JUnit46ClassesRequestBuilder.getClassesRequest(JUnit46ClassesRequestBuilder.java:51)
at com.intellij.junit4.JUnit4TestRunnerUtil.buildRequest(JUnit4TestRunnerUtil.java:91)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:39)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:212)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:68)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140)