cucumber / cucumber-eclipse

Eclipse plugin for Cucumber
MIT License
192 stars 148 forks source link

.feature doesn't work with import from io.cucumber but work with cucumber.api #368

Open kennethoys opened 5 years ago

kennethoys commented 5 years ago

Eclipse 4.10.0 2018-12 Cucumber Eclipse Plugin 0.0.23.201811220126

image

With io.cucumber image

image

With deprecated cucumber.api image

image

timtebeek commented 5 years ago

@qvdk The annotations were moved to io.cucumber in 4.5.x ahead of a 5.x release; What would be needed for the plugin to pick up these changes? Should we upgrade the library versions in https://github.com/cucumber/cucumber-eclipse/tree/master/cucumber.eclipse.backends.java/lib ? Or do you recon any other changes would be needed?

qvdk commented 5 years ago

Hi @timtebeek

The upgrade of cucumber libraries will not solve this issue. Unfortunatelly, the plugin does not delegate the work to the cucumber library itself. Presently, the plugin have its own implementation to resolve glue and gherkin analysis. This is an issue. Idealy, the plugin should delegate all works to cucumber itself. The user should be able to choose its cucumber version as the JDK and JRE can be added in Eclipse. Then, the plugin should play with the selected version of cucumber.

For now, as a workaround, you need to play with cucumber.eclipse.steps.jdt.JavaStepDefinitionsProvider. Its job is to parse Java files to search gherkin step definition implementations.

You will see in the first lines:

private final Pattern cukeAnnotationMatcher = Pattern.compile("cucumber\\.api\\.java\\.([a-z_]+)\\.(.*)$");
private static final String CUCUMBER_API_JAVA = "cucumber.api.java.";
private static final String CUCUMBER_API_JAVA8 = "cucumber.api.java8.";
private static final String REGEX_JAVA8_CUKEAPI = "cucumber\\.api\\.java8\\.(.*)";

This constants are used in this class to search the imports of Given, When, and other Gherkin keywords. Thus to be compliant with those of the Cucumber 5.x, the plugin should be able to parse both, or to detect the cucumber version used to search only the right packages.

Hope that helps.

timtebeek commented 5 years ago

Pushed some code to a branch just now in #369 ; Could you have a look if this matches what you envisioned?

RusmanCool commented 5 years ago

@timtebeek I have the latest plugin version from ZIP archive(v 1.0.0.201907020018), and the issue is still present in Eclipse Version: 2019-06 (4.12).

laeubi commented 5 years ago

@timtebeek is there a simple project I can download that uses the new annotation? I'll then take a look at this, shouldn't be a problem. The problem with delegation to cucumber itself is, that the cucumber code is not very "IDE friendly" and clearly optimized for internal use only. Even worse, with Gherking6 the decided to not even provide real java support but packing some large GO binaries to do the job so it would be nearly impossible to get any sensible information from cucumber/gherking itself in an IDE like fashion see https://github.com/cucumber/cucumber/issues/425 https://github.com/cucumber/cucumber/issues/589

timtebeek commented 5 years ago

@laeubi Thanks for offering to help! @qvdk mentioned he usually ust plays around with the cucumber-jvm examples in https://github.com/cucumber/cucumber-jvm/tree/master/examples .

Note that the cucumber-jvm examples were changed to use cucumber expressions rather than regular expressions over a year ago, but it's unclear whether the plugin presently supports both: https://github.com/cucumber/cucumber-jvm/commit/a4a3ad59d6a3769357d0a42b141c2fce444edd63#diff-bfebe34154a0dfd9fc7b447fc9ed74e9

mpkorstanje commented 5 years ago

@laeubi

The problem with delegation to cucumber itself is, that the cucumber code is not very "IDE friendly" and clearly optimized for internal use only.

I am aware that it is a problem. But I'm unfamiliar with the needs of an IDE to really account for it. Would you be able to create a few tickets that outline the things that need to be facilitated?

Even worse, with Gherking6 the decided to not even provide real java support

I don't expect Cucumber JVM will use Gherkin 6 until it does.

laeubi commented 5 years ago

@mpkorstanje thanks for offering support in that area, should I file issues against https://github.com/cucumber/cucumber-jvm/issues ? One issue for example is that we can't access the parsed tree of cucumber expressions, but that might be an issue of cucumber-expresions? It's really a little bit confusing and hard to decide where to place these issues :-)

mpkorstanje commented 5 years ago

When in doubt I'd start with Cucumber-JVM. I also think we may need to use something that isn't tied quite so strictly to a specific Cucumber JVM implementation version (i.e. a JSON representation) so hopefully the Cucumber expressions shouldn't come into it so much.

timtebeek commented 5 years ago

Added a comment to https://github.com/cucumber/cucumber-jvm/issues/1711#issuecomment-520132677 which might be relevant here; it's a new approach at running a plugin in cucumber-jvm itself to let it tell you which lines in .features match which lines in .java files. Hope it helps getting 5.0 support off the ground, and could remove the need for a parallel feature discovery layer in cucumber-eclipse.

laeubi commented 2 years ago

We are currently developing a new version of the cucumber-plugin with improved support for more recent cucumber versions, if you like try out the following update-site (please uninstall the old plugin before): https://cucumber.github.io/cucumber-eclipse/update-site/main/

ryanh007 commented 2 years ago

Does this require a minimum version of eclipse? Getting the errors below using 2020-06 (4.16) even after uninstalling the old cucumber version thx!

Cannot complete the install because of a conflicting dependency.
  Software being installed: Cucumber Eclipse 2.0.0.202109141006 (cucumber.eclipse.feature.feature.group 2.0.0.202109141006)
  Software currently installed: Eclipse Java Development Tools 3.18.400.v20200604-0540 (org.eclipse.jdt.feature.group 3.18.400.v20200604-0540)
  Only one of the following can be installed at once: 
    Java Code Manipulation Functionality 1.14.0.v20200526-0740 (org.eclipse.jdt.core.manipulation 1.14.0.v20200526-0740)
    Java Code Manipulation Functionality 1.14.400.v20210531-0737 (org.eclipse.jdt.core.manipulation 1.14.400.v20210531-0737)
  Cannot satisfy dependency:
    From: Cucumber Eclipse 2.0.0.202109141006 (cucumber.eclipse.feature.feature.group 2.0.0.202109141006)
    To: org.eclipse.equinox.p2.iu; io.cucumber.eclipse.java [2.0.0.202109141006,2.0.0.202109141006]
  Cannot satisfy dependency:
    From: Java 2.0.0.202109141006 (io.cucumber.eclipse.java 2.0.0.202109141006)
    To: osgi.bundle; org.eclipse.jdt.core.manipulation 1.14.200
  Cannot satisfy dependency:
    From: Eclipse Java Development Tools 3.18.400.v20200604-0540 (org.eclipse.jdt.feature.group 3.18.400.v20200604-0540)
    To: org.eclipse.equinox.p2.iu; org.eclipse.jdt.core.manipulation [1.14.0.v20200526-0740,1.14.0.v20200526-0740]
laeubi commented 2 years ago

You should at least use 2021-03 as this release contains an important fix / API improvement.

timtebeek commented 2 years ago

I think this issue has since been solved in newer releases. I'd suggest closing this one if you all agree .

ryanh007 commented 2 years ago

Not sure if my setup is wrong, but still cant get steps to match glue code. Also when I right click on the feature file I see no Cucumber options (Pretty format, Find Step, Scan etc) and the keyboard shortcut to create the step is not recognized. Java 11, Eclipse 2021-12, Cucumber plugin 2.0.0.202110241342, Cucumber v6.11.0

Edit: Nevermind, added my feature folder as a source and seems to work, but still not seeing the right click options?

Thanks for plugin, this is super helpful!

nramu33 commented 2 years ago

@ryanh007 could you please share me the link to get Cucumber plugin 2.0.0.202110241342.

ryanh007 commented 1 year ago

@nramu33 It used to be on https://cucumber.github.io/cucumber-eclipse/update-site/main/ but looks like that got pulled down. Not seeing any other way to get 2.X. Is the support for this plugin End of Life at this point?

mpkorstanje commented 1 year ago

The update site is still there. You have to add it to Eclipse, not visit it with your web browser.