Error: Please specify non-empty path to Cucumber package

已回答

When build with Intelij: Used to get error "Please specify non-empty path to Cucumber package".


 

When tried to build with command prompt with command "gradle cucumber" it build successful.

 Below are the details:

 

Feature File:

Feature: Is it Friday yet?
Everybody wants to know when it's Friday

Scenario: Sunday isn't Friday
Given today is Sunday
When I ask whether it's Friday yet
Then I should be told "Nope"

 

Step Definition File:

package hellocucumber;

import cucumber.api.PendingException;
import cucumber.api.java.en.Given;
import cucumber.api.java.en.When;
import cucumber.api.java.en.Then;
import static org.junit.Assert.*;

class IsItFriday {
static String isItFriday(String today) {
return "Nope";
}
}

public class MyStepdefs {
private String today;
private String actualAnswer;

@Given("^today is Sunday$")
public void today_is_Sunday() {
this.today = "Sunday";
}

@When("^I ask whether it's Friday yet$")
public void i_ask_whether_is_s_Friday_yet() {
this.actualAnswer = IsItFriday.isItFriday(today);
}

@Then("^I should be told \"([^\"]*)\"$")
public void i_should_be_told(String expectedAnswer) {
assertEquals(expectedAnswer, actualAnswer);
}
}

 

Above i have mentioned output with - Intellij & command prompt.

 

Build.gradle code:


configureBuild(project, ['java', 'spring-boot', 'dependencies', 'publish', 'cf'])
configurations {
cucumberRuntime {
extendsFrom testRuntime
}
}
dependencies {
implementation project(':api')

testCompile 'io.cucumber:cucumber-java:2.4.0'
}

task cucumber() {
dependsOn assemble, compileTestJava
doLast {
javaexec {
main = "cucumber.api.cli.Main"
classpath = configurations.cucumberRuntime + sourceSets.main.output + sourceSets.test.output
args = ['--plugin', 'pretty', '--glue', 'gradle.cucumber', 'src/test/resources']
}
}
}

 

Please help me how to test/ run the features successfully.

0

Hello,

Works fine on my machine with test project. Could you please share project example for investigation?

 

0
Avatar
Permanently deleted user

I am not sure whether i am authorized to share the project or not.

However, if you can share your project if possible to my email id hgupta.99@gmail.com.

or any screen shot of command prompt or Intellij would also be helpful.

 

0
Avatar
Permanently deleted user

I downloaded the project & did the same, but no luck. Still getting the same error. You can see the error message at the bottom left side of screen shot.

 

0

Could you please attach screenshot showing your Run configuration?

0
Avatar
Permanently deleted user

0

Wrong configuration is used. It should be "Cucumber java", not "Cucumber.js". Please try to manually create proper configuration or disabe "Cucumber js" plugin, so proper default configuration will be suggested.

0
Avatar
Permanently deleted user

Thanks.

Can you please share the screenshot of your project's configuration.

 

I am referring from : https://www.jetbrains.com/help/idea/run-debug-configuration-cucumber-java.html. I am not sure which all options i need to fill. 

0
Avatar
Permanently deleted user

I started getting this error:

 

Exception in thread "main" cucumber.runtime.CucumberException: gherkin.ParserException$CompositeParserException: Parser errors:
(5:5): expected: #EOF, #TableRow, #DocStringSeparator, #StepLine, #TagLine, #ScenarioLine, #ScenarioOutlineLine, #Comment, #Empty, got 'then it should will fail'
at cucumber.runtime.FeatureBuilder.parse(FeatureBuilder.java:60)
at cucumber.runtime.model.CucumberFeature.loadFromFeaturePath(CucumberFeature.java:113)
at cucumber.runtime.model.CucumberFeature.load(CucumberFeature.java:49)
at cucumber.runtime.model.CucumberFeature.load(CucumberFeature.java:31)
at cucumber.runtime.RuntimeOptions.cucumberFeatures(RuntimeOptions.java:311)
at cucumber.runtime.Runtime.run(Runtime.java:95)
at cucumber.api.cli.Main.run(Main.java:36)
at cucumber.api.cli.Main.main(Main.java:18)
Caused by: gherkin.ParserException$CompositeParserException: Parser errors:
(5:5): expected: #EOF, #TableRow, #DocStringSeparator, #StepLine, #TagLine, #ScenarioLine, #ScenarioOutlineLine, #Comment, #Empty, got 'then it should will fail'
at gherkin.Parser.parse(Parser.java:143)
at gherkin.Parser.parse(Parser.java:118)
at gherkin.Parser.parse(Parser.java:114)
at cucumber.runtime.FeatureBuilder.parse(FeatureBuilder.java:56)
... 7 more

0
Avatar
Permanently deleted user

0

I used default configuration:

0
Avatar
Permanently deleted user

Now, I am getting :

Error running 'Feature: test': Command line is too long. Shorten command line for Feature: test or also for Cucumber java default configuration.

 

 

0
Avatar
Permanently deleted user

Resolved it by 

<property name="dynamic.classpath" value="true" />
0

There is related request about missing "shorten classpath" option on YouTrack: https://youtrack.jetbrains.com/issue/IDEA-184133

0

请先登录再写评论。