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

Support for pure Kotlin tests (needed for Kotlin Multiplatform) #331

Open
davidvavra opened this issue Feb 7, 2018 · 10 comments
Open

Support for pure Kotlin tests (needed for Kotlin Multiplatform) #331

davidvavra opened this issue Feb 7, 2018 · 10 comments
Labels
language: kotlin ⚡ enhancement Request for new functionality

Comments

@davidvavra
Copy link

Kotlin now has support for multiplatform projects. Common code is written in pure Kotlin (no Java dependencies are possible) and then developer creates modules like common-jvm and common-js which can contain JVM or JS dependencies. The code in the common module should be tested and Jetbrains created annotations in kotlin.test package which are automatically translated into JUnit or JS tests. Then tests can run on all platforms with no work. More documentation here.

So currently cucumber can be used only in common-jvm or common-js modules, but not in the common module. Which means writing step definitions twice. It would be great if cucumber supported kotlin.test tests directly.

@mlvandijk
Copy link
Member

mlvandijk commented Feb 8, 2018

Would this be a separate Kotlin implementation of Cucumber, or an addition to cucumber-jvm? I've only recently started using Kotlin myself, and we use it in combination with Java atm, so I'm not sure what would be needed to make this work.
Thanks for the link; will have a look later!

@davidvavra
Copy link
Author

@mlvandijk Imho separate Kotlin implementation. Normally Kotlin is built on top of JVM and normal Java version can be used. But it's different for multiplatform projects.

@mlvandijk
Copy link
Member

@davidvavra The link you provided states: "Multiplatform projects are a new experimental feature in Kotlin 1.2. All of the language and tooling features described in this document are subject to change in future Kotlin versions." So if someone were to create a pure Kotlin implementation of Cucumber, imho it might be best to wait until this is sorted out in Kotlin to prevent rework.

@aslakhellesoy
Copy link
Contributor

A Kotlin implementation of Cucumber would be fantastic!

Writing a new Cucumber implementation from scratch is a considerable amount of work. There are several libraries to implement:

  • Gherkin Parser (unless you run an existing gherkin cli/exe)
  • Cucumber Expressions (unless you only want to support RegExp)
  • Tag Expressions
  • Language-specific DSL for step definitions and hooks
  • Runtime/execution engine

Would you be interested in (and able to) kick this off @davidvavra?

@aslakhellesoy aslakhellesoy added ⚡ enhancement Request for new functionality language: kotlin labels Feb 10, 2018
@davidvavra
Copy link
Author

That looks like a lot of work. I agree with @mlvandijk that the feature is still experimental and we should probably wait a while until it's more stable. But it's good to have an open issue and track progress/gather interest. I'm not interested in kicking off the implementation, but maybe I can help with some smaller tasks.

@stale
Copy link

stale bot commented Apr 13, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in a week if no further activity occurs.

@stale stale bot added the ⌛ stale Will soon be closed by stalebot unless there is activity label Apr 13, 2018
@mlvandijk mlvandijk added 🧷 pinned Tells Stalebot not to close this issue and removed ⌛ stale Will soon be closed by stalebot unless there is activity labels Apr 16, 2018
@aslakhellesoy
Copy link
Contributor

This should get easiers when we get further through the roadmap.

@mattwynne
Copy link
Member

Is anyone still interested in tackling this?

@mattwynne mattwynne added ⌛ stale Will soon be closed by stalebot unless there is activity and removed 🧷 pinned Tells Stalebot not to close this issue labels Jun 9, 2021
@stale stale bot removed the ⌛ stale Will soon be closed by stalebot unless there is activity label Jun 9, 2021
@mkrussel77
Copy link

It might be easier to port instead of rewriting. If it is an independent implementation, then both implementations have to be maintained, but if the old is ported to Kotlin Multiplatform then it can be used for both Java (JVM) testing and Kotlin Multiplatform testing.

The approach I would take would be:

  1. Port the Java code to Kotlin
  2. Convert from Maven to Gradle (there's a lot more resources out there on KMP using Gradle than with Maven)
  3. Replace libraries with ones that support Kotlin Multiplatform
  4. Switch any IO to using something like okio
  5. Enable Kotlin Mulitplatform
  6. Fix errors for code that was still using JVM specific classes

This could even be done would module at a time.

@mpkorstanje
Copy link
Contributor

if the old is ported to Kotlin Multiplatform then it can be used for both Java (JVM) testing and Kotlin Multiplatform testing.

Unfortunately this adds a dependency on the Kotlin standard library.

This is a non-trivial piece of complexity added to every project that uses Cucumber.

Cucumber is used as a testing library. This additional complexity may make a test run less representative. So generally speaking we try to avoid introducing additional depencies (or at the very least shade then).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
language: kotlin ⚡ enhancement Request for new functionality
Projects
None yet
Development

No branches or pull requests

6 participants