Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
maioni opened this issue Jun 13, 2022 · 20 comments

Comments

@maioni
Copy link

maioni commented Jun 13, 2022

👓 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
Copy link
Contributor

laeubi commented Jun 14, 2022

3. 'Eclipse Cucumber Plugin' version '1.0.0.202106240526'

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

@maioni
Copy link
Author

maioni commented Jun 14, 2022

  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
Copy link
Contributor

laeubi commented Jun 14, 2022

@maioni
Copy link
Author

maioni commented Jun 14, 2022

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
Copy link
Contributor

laeubi commented Jun 14, 2022

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
Copy link
Author

maioni commented Jun 14, 2022

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
Copy link
Contributor

laeubi commented Jun 15, 2022

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
Copy link
Contributor

laeubi commented Jun 15, 2022

Also make sure to use a recent eclipse version.

@maioni
Copy link
Author

maioni commented Jun 15, 2022

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
Copy link
Contributor

laeubi commented Jun 15, 2022

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
Copy link
Author

maioni commented Jun 15, 2022

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
Copy link
Author

maioni commented Jun 15, 2022

Same issue with the example project:

image

@maioni
Copy link
Author

maioni commented Jun 15, 2022

@laeubi the issue is open: #459

@laeubi
Copy link
Contributor

laeubi commented Jun 15, 2022

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
Copy link
Author

maioni commented Jun 16, 2022

How to install Plugin properly details at: #459

@maioni maioni closed this as completed Jun 16, 2022
@maioni
Copy link
Author

maioni commented Jun 16, 2022

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:

  • Feature
    /java-calculator/src/test/resources/io/cucumber/examples/calculator/basic_arithmetic.feature
  • Step
    /java-calculator/src/test/java/io/cucumber/examples/calculator/RpnCalculatorSteps.java

And updating the step code at line 19:

  • From:
    @Given("a calculator I just turned on")
    public void a_calculator_I_just_turned_on() {
        calc = new RpnCalculator();
    }

image

  • To:
import io.cucumber.java.ParameterType;

...

@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

ISSUE

  1. When we try to HOLD LEFT CTRL key and do a mouse CLICK on line 9:
    image

  2. It can't find the step definition:
    image

@maioni maioni reopened this Jun 16, 2022
@laeubi
Copy link
Contributor

laeubi commented Jun 16, 2022

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
Copy link
Author

maioni commented Jun 16, 2022

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
Copy link
Author

maioni commented Jun 16, 2022

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

@maioni
Copy link
Author

maioni commented Jun 16, 2022

New issue opened: #460

@maioni maioni closed this as completed Jun 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants