jeudi 25 février 2016

feature file can not see steps in cucumber tests

I have the next project structure:

src/
    |
    | --main/
    |     --java/
    |        --cucumber/
    |        --CucumberRunner
    |        --features
    |          --MyFeatures.feature
    |          --StepDefinitions.java

My Runner:

@RunWith(Cucumber.class)
@CucumberOptions(
        format ={"pretty", "json:target/cucumber.json"},
        features = {"src/main/java"}
)
public class CucumberRunner {

}

I know that path is incorrect here but I tried all possible combinations - the result is the same((( My feature:

Feature: Testing my simple kickstarter project

  Scenario: My first test
    Given I navigate to Categories page
    When When I enter 'f'
    Then Error is displayed

My steps:

public class StepDefinitions {
    @Given("^I navigate to Categories page$")
    public void i_navigate_to_Categories_page() throws Throwable {
        // Write code here that turns the phrase above into concrete actions
        throw new PendingException();
    }

    @When("^When I enter 'f'$")
    public void when_I_enter_f() throws Throwable {
        // Write code here that turns the phrase above into concrete actions
        throw new PendingException();
    }

    @Then("^Error is displayed$")
    public void error_is_displayed() throws Throwable {
        // Write code here that turns the phrase above into concrete actions
        throw new PendingException();
    }
}

The problem is that feature file can not see its steps((

Test ignored.
Test ignored.
Test ignored.
Test ignored.
Test ignored.
Test ignored.Feature: Testing my simple kickstarter project
  Scenario: My first test               # features/myFeatures.feature:3
    Given I navigate to Categories page
    When When I enter 'f'
    Then Error is displayed

1 Scenarios (1 undefined)
3 Steps (3 undefined)
0m0.000s


You can implement missing steps with the snippets below:
....

What can be the problem?

Aucun commentaire:

Enregistrer un commentaire