rlogiacco / Natural

Natural is a collection of Eclipse plugins to enable rich smart editing of acceptance tests using natural language definition files. It currently supports Cucumber and JBehave syntax.
Eclipse Public License 1.0
75 stars 37 forks source link

Problem linking steps to step definition methods #51

Closed tome57a closed 4 years ago

tome57a commented 7 years ago

I am having a problem linking step definition methods to steps in my project. My environment is Eclipse Neon.3 on Windows 10 with the Natural 0.7.6 plugin installed. The code is as follows:

Feature file ProofOfConcept.feature:

Feature: ProofOfConcept 
    As a BDD enthusiast
    I want to demonstrate working Cucumber (Gherkin) scenarios
    So that we can incorporate BDD into our projects
Scenario: Simple Test One
    Given I Am Logged In To The App 
    When I click My Account 
    Then I see the My Account screen

The compiler is flagging the steps with 'no definition found' warnings.

Step definition file ProofOfConceptSteps.java:

package cucumber.stepDefinitions;
import org.agileware.natural.*;
public class ProofOfConceptSteps {
    @Given("I Am Logged In To The App")
    public void GivenIAmLoggedInToTheApp() {
        // TODO
    }
}

The compiler is flagging the "@Given" line with the error "Given cannot be resolved to a type".

In the project, org.agileware.natural.*jar are added as Referenced Libraries. This project also uses Gradle to build but I have no idea what if anything to put into the build.gradle file to make this work. I tried adding the following line in the file's dependencies section but it doesn't help: compile 'org.agileware.natural:0.7.6'

I've been unable to find sample code on the web to show the proper way to do this, and at this point I am stuck.

Thanks for any help!

Tom

drkstr101 commented 4 years ago

I am taking a look into this now.

Also see: https://github.com/rlogiacco/Natural/issues/74

drkstr101 commented 4 years ago

Oops, never mind.

The compiler is flagging the "@given" line with the error "Given cannot be resolved to a type".

It looks like you need to import your annotations, and/or correct the capitalization of your @Given annotation.

rlogiacco commented 4 years ago

I'll try to step in, maybe I can help solve this. Importing org.agileware.natural.* is of absolutely no use to you, you must refer to the classes defined in the Cucumber JVM project, thus importing io.cucumber.java.en.*. The same applies to the libraries you are referencing: Natural is an Eclipse plugin, not a BDD library, meaning you never import our library, you just use our plugin to help you out in using either Cucumber or JBehave. In your case you want to either import cucumber-java or cucumber-java8: https://cucumber.io/docs/cucumber/step-definitions/.

Feel free to reopen if I misunderstood your question.