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

[Core] CLI should search classpath root by default #1889

Merged
merged 2 commits into from
Feb 6, 2020

Conversation

mpkorstanje
Copy link
Contributor

@mpkorstanje mpkorstanje commented Feb 6, 2020

The Cucumber CLI is rather complex to use. To work correctly it needs both
a --glue parameter in the form of a package name and a location of a feature
file in form of a classpath uri or path. As a result people often configure
Cucumber incorrectly and are left wondering why their features or glue can not
be found.

This can be simplified as shown by the Cucumber Platform Engine which defaults
to the classpath root and the JUnit and TestNG runners which default to the
package of the runner class.

So it makes sense to do the same with the CLI.

Assuming the following project layout the CLI can discover and execute
all features without needing additional arguments.

├── pom.xml
├── src
│   ├── main
│   │   └── java
│   │       └── com/example/Application.java
│   └── test
│       ├── java
│       │   └── com/example/StepDefinitions.java
│       └── resources
│           └── com/example/example.feature

This can be done with a single maven command:

mvn exec:java                                  \
    -Dexec.classpathScope=test                 \
    -Dexec.mainClass=io.cucumber.core.cli.Main

Additional benefits can be found in the fact that IDEA often can't work out
which package should be used as glue and does not provide it. The Cucumber Eclipse
plugin on the other hand always defaults to the class path root.

Types of changes

  • Bug fix (non-breaking change which fixes an issue).
  • New feature (non-breaking change which adds functionality).
  • Breaking change (fix or feature that would cause existing functionality to not work as expected).

Checklist:

  • I've added tests for my code.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.

@mpkorstanje mpkorstanje changed the title [Core] CLI should search classpath root for glue and features by default [Core] CLI should search classpath root by default Feb 6, 2020
@mpkorstanje mpkorstanje force-pushed the default-glue-to-classpath-root branch 2 times, most recently from d322e3a to ad9e931 Compare February 6, 2020 21:54
The Cucumber CLI is rather complex to use. To work correctly it needs both
a `--glue` parameter in the form of a package name and a location of a feature
file in form of a classpath uri or path. As a result people often configure
Cucumber incorrectly and are left wondering why their features or glue can not
be found.

This can be simplified as shown by the Cucumber Platform Engine which defaults
to the classpath root and the JUnit and TestNG runners which default to the
package of the runner class.

So it makes sense to do the same with the CLI.

Assuming the following project layout the CLI can discover and execute
all features without needing additional arguments.

```
├── pom.xml
├── src
│   ├── main
│   │   └── java
│   │       └── com/example/Application.java
│   └── test
│       ├── java
│       │   └── com/example/StepDefinitions.java
│       └── resources
│           └── com/example/example.feature
```

This can be with a single maven command:

```
mvn exec:java                                  \
    -Dexec.classpathScope=test                 \
    -Dexec.mainClass=io.cucumber.core.cli.Main
```

Additional benefits can be found in the fact that IDEA often can't work out
which package should be used as glue and does not provide a default. The
Cucumber Eclipse plugin on the other hand always defaults to the class path
root.

Fixes: #1875
@mpkorstanje mpkorstanje force-pushed the default-glue-to-classpath-root branch from ad9e931 to 4c63005 Compare February 6, 2020 21:56
@coveralls
Copy link

coveralls commented Feb 6, 2020

Coverage Status

Coverage increased (+0.0006%) to 82.977% when pulling c810c7f on default-glue-to-classpath-root into adc0479 on master.

@mpkorstanje mpkorstanje merged commit 02c6972 into master Feb 6, 2020
@mpkorstanje mpkorstanje deleted the default-glue-to-classpath-root branch February 6, 2020 22:19
@mpkorstanje mpkorstanje added this to the 5.x.x milestone Feb 6, 2020
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

Successfully merging this pull request may close these issues.

2 participants