Skip to content

[JUnit] Implement Cucumber as a Junit Platform Engine #1530

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

Merged
merged 98 commits into from
Nov 21, 2019
Merged

Conversation

mpkorstanje
Copy link
Contributor

@mpkorstanje mpkorstanje commented Jan 4, 2019

Summary

Adds Cucumber implementation of JUnit Platforms TestEngine that will discover, filter and execute scenarios.

Fixes: #1149

Details

Motivation and Context

The motivation for this PR is two fold. To reduce the amount of configuration needed to run Cucumber and to facilitate developers of tooling that integrates Cucumber into test runners and IDE's.

Facilitating tooling

Unlike previous versions of JUnit, JUnit 5 is composed of several different modules from three different sub-projects.

JUnit 5 = JUnit Platform + JUnit Jupiter + JUnit Vintage

The JUnit Platform serves as a foundation for launching testing frameworks on the JVM. It also defines the TestEngine API for developing a testing framework that runs on the platform. By implementing Cucumber as a TestEngine we can benefit from existing implementations that use the JUnit Platform. This will make it easier to develop tooling for Cucumber - any tooling that supports the Junit Platform will automatically support the execution of Cucumber Scenarios. For example:

image

Note: Support is limited to running cucumber tests. Syntax highlighting, and other editor specific features are not supported.

Reduce boiler plate

In the ideal situation a project only contains step definitions and feature files. Currently however some additional setup is needed in the form of a runner class annotated with @CucumberOptions. By using the JUnit platform the presence of Cucumber on the class path will make it so that tooling can automatically execute features.

Coincidentally the JUnit Platform only allows a single source of configuration. This makes it clear in which configuration cucumber will be executed. This is an improvement over the current hierarchy of environment and annotation based variables.

How Has This Been Tested?

Work in progress

  • Map ConfigurationParameters to RuntimeOptions in CucumberEngineExecutionContext. This will require some refactoring of RuntimeOptions. Note that not all options are valid in this context. Valid options are: --dry-run, --monochrome, --strict, --plugin and --glue.
  • Document the available configuration parameters and how to use them in maven. Comparable to the documentation for Junit 5 itself.
  • Resolve features suggested by ModuleSelector in DiscoverySelectorResolver
  • Resolve features suggested by ClasspathRootSelector in DiscoverySelectorResolver
  • Resolve features suggested by UniqueIdSelector in DiscoverySelectorResolver
  • Resolve features suggested by UriSelector in DiscoverySelectorResolver.
  • Implement getTags for PickleDescriptor, ScenarioOutlineDescriptor and FeatureFileDescriptor.
  • Ensure IDEA picks up the CucumberTestEngine implementation. See: Add JUnit 5 Support #1149 (comment)
  • Submit a patch Maven Surefire the JunitPlatformProvider to support non-class files. See: Add JUnit 5 Support #1149 (comment)

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 and others added 30 commits March 10, 2018 20:55
To avoid having to deal with path separators everywhere all paths have
their separators replaced with a forward slash while parsing runtime
options. To make this easier all rerun files are also read while parsing
runtime options.

As a result we can now also emit an error when a feature file that explicitly
included (e.g. /path/to.feature) does not exist.
@tsundberg tsundberg modified the milestones: 5.0.0, 5.x.x Nov 20, 2019
@mpkorstanje mpkorstanje changed the title WIP: Add JUnit 5 Support [JUnit] Implement Cucumber as a Junit Platform Engine Nov 21, 2019
@mpkorstanje mpkorstanje merged commit fdef80f into master Nov 21, 2019
@mpkorstanje mpkorstanje deleted the junit-jupiter branch November 21, 2019 16:24
@mpkorstanje mpkorstanje restored the junit-jupiter branch November 21, 2019 17:35
mpkorstanje added a commit that referenced this pull request Nov 21, 2019
Adds Cucumber implementation of JUnit Platforms TestEngine that will discover,
filter and execute scenarios.

Fixes: #1149

Unlike previous versions of JUnit, JUnit 5 is composed of several different
modules from three different sub-projects.

```
JUnit 5 = JUnit Platform + JUnit Jupiter + JUnit Vintage
```

The JUnit Platform serves as a foundation for launching testing frameworks on
the JVM. It also defines the TestEngine API for developing a testing framework
that runs on the platform. By implementing Cucumber as a TestEngine we can
benefit from existing implementations that use the JUnit Platform. This will
make it easier to develop tooling for Cucumber - any tooling that supports the
Junit Platform will automatically support the execution of Cucumber Scenarios.
@mpkorstanje mpkorstanje deleted the junit-jupiter branch November 21, 2019 17:42
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.

Add JUnit 5 Support
7 participants