cucumber / common

A home for issues that are common to multiple cucumber repositories
https://cucumber.io/docs
MIT License
3.36k stars 694 forks source link

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

Open davidvavra opened 6 years ago

davidvavra commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

@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 commented 6 years ago

@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 commented 6 years ago

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:

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

davidvavra commented 6 years ago

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[bot] commented 6 years ago

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.

aslakhellesoy commented 6 years ago

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

mattwynne commented 3 years ago

Is anyone still interested in tackling this?

mkrussel77 commented 2 years ago

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 commented 2 years ago

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).