JGiven icon indicating copy to clipboard operation
JGiven copied to clipboard

introduce jgiven-kotlin

Open jangalinski opened this issue 5 years ago • 3 comments

Kotlin is working just fine with jgiven, but in day to day usage, some problems occur. This module provides useful fixes and extensions:

  • it contains a JGivenStage annotation that can be used to configure the kotlin "all-open" plugin, otherwise stage classes and all stage methods would have to be explicitly marked as open
  • "when" is a keyword in kotlin, so Stage.when() has to be written as Stage.'when'() ... I introduced extension properties for given()/when()/then()/... so a kotlin test can be written like:
class JGivenKotlinExtensionTest : ScenarioTest<JGivenKotlinGiven, JGivenKotlinWhen, JGivenKotlinThen>() {

  @Test
  fun `add two numbers`() {
    GIVEN
        .number(5)

    WHEN
        .we_add_number(7)

    THEN
        .the_result_is(12)
  }
}

What do you think?

Attention: this is just a kick-off PR, if you would integrate this into jgiven, we'd have to set up the dokka plugin for java doc generation.

jangalinski avatar May 10 '19 09:05 jangalinski

@janschaefer did you have a chance to have a look into this?

jangalinski avatar Jun 04 '19 12:06 jangalinski

As far as I can evaluate it (I am not a Kotlin developer) it looks good. I am not a big fan of all uppercase GIVEN, WHEN, THEN, but I guess lower case is not possible and it is just my taste.

janschaefer avatar Jun 05 '19 18:06 janschaefer

Hi, what is the state of this PR? Any chance to consider support for kotlin for 1.0.0?

jangalinski avatar Jul 16 '20 13:07 jangalinski