cucumber / cucumber-eclipse

Eclipse plugin for Cucumber
MIT License
190 stars 147 forks source link

Gherkin: .feature can't find a .step definition when it uses a parametertype on it #458

Closed maioni closed 2 years ago

maioni commented 2 years ago

👓 What did you see?

The .feature file (the gherkin) cant find the step definition when it's using a @parametertype value on it.

Files content

.feature image Feature: Pages I want to use the menu page

Scenario: Click on menu Given I click on menu

.step image @Then("I click on {menu}")

@ParameterType("menuitema|menuitemb|menuitemc") public String menu(String menu) { if ("menuitema|menuitemb|menuitemc".contains(menu)) { return menu; } return ""; }

✅ What did you expect to see?

The Gherkin should find the step definition, and the step definition should found the parameter type definition, this way we can CTRL + CLICK on feature to goes to the step definition.

📦 Which tool/library version are you using?

Eclipse + Eclipse Cucumber Plugin

🔬 How could we reproduce it?

Steps to reproduce the behavior:

  1. Install 'Eclipse IDE for Enterprise Java and Web Developers (includes Incubating components)' Version: '2022-03 (4.23.0)' Build id: '20220310-1457'
  2. Create a Maven Project
  3. Install the 'Eclipse Cucumber Plugin' version '1.0.0.202106240526' at 'Eclipse Marketplace'
  4. Convert the project to Cucumber: Open the contextual menu from your project - right click - Configure > Convert as cucumber project…
  5. Clean project: Project > Clean…
  6. Open the .feature file
  7. Hold CTRL and click on the feature to goes to the step definition location

📚 Any additional context?

Parameter Type: https://cucumber.io/docs/cucumber/configuration/?sbsearch=Parameter%20type Cucumber Expressions: Parameter type (https://cucumber.io/blog/open-source/announcing-cucumber-expressions/?sbsearch=parameter%20type)


This text was originally generated from a template, then edited by hand. You can modify the template here.

laeubi commented 2 years ago

3. 'Eclipse Cucumber Plugin' version '1.0.0.202106240526'

this is only supported on the current developed 2.x version of cucumber.

maioni commented 2 years ago
  1. 'Eclipse Cucumber Plugin' version '1.0.0.202106240526'

this is only supported on the current developed 2.x version of cucumber.

How install the 2.0 version?

laeubi commented 2 years ago

See https://github.com/cucumber/cucumber-eclipse#follow-the-latest-snapshot

maioni commented 2 years ago

See https://github.com/cucumber/cucumber-eclipse#follow-the-latest-snapshot

Unable to follow this guide due to a broken link:

404 - file not found > eclipse update site for the cucumber eclipse plugin: https://cucumber.github.io/cucumber-eclipse/update-site/main/

laeubi commented 2 years ago

Unable to follow this guide due to a broken link

This is an updatesite link not for a webbrowser, just enter it into Help>Install new Software

maioni commented 2 years ago

at Eclipse: Help > Install New Software image

Add Name: Cucumber Eclipse Plugin 2.0 Location: https://cucumber.github.io/cucumber-eclipse/update-site/main/ image Add

Select Cucumber Eclipse Plugin, Ansi Console, third party dependencies image image Next

If 1.0 was installed, it will be updated to 2,0 instead: image

Select All image Trust Selected

image Restart Now

PROBLEM! After install 2.0, the options to convert project to cucumber is absent, and .feature files are no more associated to cucumber: @laeubi

I tried to install 2.0 after 1.0 to upgrade it, but the issue remains, and I couldn't associate .feature to cucumber properly:

Steps: Install Cucumber Eclipse Plugin 1.0 image Restart Eclipse

At Project, select it with right click and Configure > Convert to Cucumber Project... [OPTION ABSENT WITH 2.0, ONLY AVAILABLE WITH 1.0] image

Select Project and Clean... image

Now the feature and steps are correctly linked. [ONLY WORKED WITH 1.0 BUT NOT COMPATIBLE WITH CUCUMBER 6/7 NEW FEATURES LIKE PARAMETER TYPE, UNABLE TO DO IT WITH 2.0 DUE TO PREVIOUSLY ISSUES]

laeubi commented 2 years ago

PROBLEM! After install 2.0, the options to convert project to cucumber is absent,

2.0 do not use/require a special project type anymore. Please make sure that 1.0 is uninstalled and there are no conflicting editor assignments that take precedence.

laeubi commented 2 years ago

Also make sure to use a recent eclipse version.

maioni commented 2 years ago

PROBLEM! After install 2.0, the options to convert project to cucumber is absent,

2.0 do not use/require a special project type anymore. Please make sure that 1.0 is uninstalled and there are no conflicting editor assignments that take precedence.

Using the last version, and already installed 2.0 alone, the issue remains.

image

laeubi commented 2 years ago

There is an example project here:

https://github.com/cucumber/cucumber-eclipse/tree/main/examples/java-calculator

this requires m2eclipse to be imported and then should work at least last time i tested, if not please open an issue with the steps to reproduce the problem.

maioni commented 2 years ago

Downloaded a new and updated Eclipse with already m2 installed: image But the issue remains, after install Cucumber Eclipse Plugin, the files .feature remains not associated, and the Convert project to cucumber absent.

maioni commented 2 years ago

Same issue with the example project:

image

maioni commented 2 years ago

@laeubi the issue is open: https://github.com/cucumber/cucumber-eclipse/issues/459

laeubi commented 2 years ago

Same issue with the example project:

Sorry I don't understand, your screenshot shows the green cucumber icon for the feature and it open a gherking / cucumber editor with highligts and instant run actions so what exactly are you missing?

maioni commented 2 years ago

How to install Plugin properly details at: https://github.com/cucumber/cucumber-eclipse/issues/459

maioni commented 2 years ago

After know how to install Cucumber Eclipse Plugin 2.0, and now able to test a cucumber project that uses Parameter type, the feature remains unable to find the step definition:

Updating the example calculator code to support parametertype: Original code: https://github.com/cucumber/cucumber-eclipse/tree/main/examples/java-calculator Updated code with parametertype implemented: java-calculator.zip

Looking at these files:

And updating the step code at line 19:

...

@Given("a calculator I just turned {power}") public void a_calculator_I_just_turned_on(String power) { switch (power) { case "on": calc = new RpnCalculator(); break; } }

@ParameterType("on|off")
public String menu(String power) {
    if ("on|off".contains(power)) {
        return power;
    }
    return "";
}

![image](https://user-images.githubusercontent.com/6604846/173973356-14f7517e-1ca2-40de-9a9a-2af4fbe042a4.png)

**ISSUE**

1. When we try to HOLD LEFT CTRL key and do a mouse CLICK on line 9:
![image](https://user-images.githubusercontent.com/6604846/173974184-9da6d117-e8e7-44a4-a2ca-3edea04e37c7.png)

2. It can't find the step definition:
![image](https://user-images.githubusercontent.com/6604846/173974237-cc4e3278-8903-4b6b-9ae9-4883c7519207.png)
laeubi commented 2 years ago

According to your screenshot you have not saved the RnpCalculatorStep file...

Beside that its best to enhance the example (or copy it, provide an own, ...) open a PR and a separate issue.

maioni commented 2 years ago

According to your screenshot you have not saved the RnpCalculatorStep file...

Beside that its best to enhance the example (or copy it, provide an own, ...) open a PR and a separate issue.

image

maioni commented 2 years ago

You want me to update the example code in github, that's it? Close this issue and open a new one?

maioni commented 2 years ago

New issue opened: https://github.com/cucumber/cucumber-eclipse/issues/460