-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The implementation of t he `ConstantPoolTypeIntrospector` did not fully support closures. Using a closure without scoped variables would result in a null pointer exception. E.g: ```java Given("^A statement with a body expression$") { assertTrue(true) } ``` This is resolved check if the member reference method equals the magic constant "INSTANCE" and return no type arguments. Related issues: - #1123 - #1126 This fixes #1123
- Loading branch information
1 parent
004e192
commit cd515d3
Showing
8 changed files
with
208 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
Java 8 Bindings for Kotlin | ||
========================== | ||
|
||
This module only runs tests. | ||
|
||
You can use `cucumber-java` or `cucumber-java8` directly in Kotlin. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>io.cucumber</groupId> | ||
<artifactId>cucumber-jvm</artifactId> | ||
<relativePath>../pom.xml</relativePath> | ||
<version>2.0.0-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>cucumber-kotlin-java8</artifactId> | ||
<packaging>jar</packaging> | ||
<name>Cucumber-JVM: Kotlin Java8</name> | ||
|
||
<properties> | ||
<kotlin.version>1.1.2-2</kotlin.version> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>io.cucumber</groupId> | ||
<artifactId>cucumber-java8</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.cucumber</groupId> | ||
<artifactId>cucumber-junit</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>net.sourceforge.cobertura</groupId> | ||
<artifactId>cobertura</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jetbrains.kotlin</groupId> | ||
<artifactId>kotlin-stdlib</artifactId> | ||
<version>${kotlin.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<sourceDirectory>${project.basedir}/src/main/kotlin</sourceDirectory> | ||
<testSourceDirectory>${project.basedir}/src/test/kotlin</testSourceDirectory> | ||
<plugins> | ||
<plugin> | ||
<artifactId>kotlin-maven-plugin</artifactId> | ||
<groupId>org.jetbrains.kotlin</groupId> | ||
<version>${kotlin.version}</version> | ||
<executions> | ||
<execution> | ||
<id>compile</id> | ||
<goals> | ||
<goal>compile</goal> | ||
</goals> | ||
</execution> | ||
<execution> | ||
<id>test-compile</id> | ||
<goals> | ||
<goal>test-compile</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-jar-plugin</artifactId> | ||
<configuration> | ||
<skip>true</skip> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-install-plugin</artifactId> | ||
<configuration> | ||
<skip>true</skip> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-deploy-plugin</artifactId> | ||
<configuration> | ||
<skip>true</skip> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
55 changes: 55 additions & 0 deletions
55
kotlin-java8/src/test/kotlin/cucumber/runtime/kotlin/test/LambdaStepdefs.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package cucumber.runtime.kotlin.test; | ||
|
||
import cucumber.api.DataTable | ||
import cucumber.api.Scenario | ||
import cucumber.api.java8.En | ||
import org.junit.Assert.* | ||
|
||
var lastInstance : LambdaStepdefs? = null | ||
|
||
class LambdaStepdefs : En { | ||
|
||
init { | ||
Before { scenario: Scenario -> | ||
assertNotSame(this, lastInstance) | ||
lastInstance = this | ||
} | ||
|
||
Given("^this data table:$") { peopleTable: DataTable -> | ||
val people = peopleTable.asList(Person::class.java) | ||
assertEquals("Aslak", people[0].first) | ||
assertEquals("Hellesøy", people[0].last) | ||
} | ||
|
||
val alreadyHadThisManyCukes = 1 | ||
Given("^I have (\\d+) cukes in my belly$") { n: Long -> | ||
assertEquals(1, alreadyHadThisManyCukes) | ||
assertEquals(42L, n) | ||
} | ||
|
||
val localState = "hello" | ||
Then("^I really have (\\d+) cukes in my belly") { i: Int -> | ||
assertEquals(42, i) | ||
assertEquals("hello", localState) | ||
} | ||
|
||
Given("^A statement with a body expression$") { assertTrue(true) } | ||
|
||
Given("^A statement with a simple match$", { -> assertTrue(true) }) | ||
|
||
val localInt = 1 | ||
Given("^A statement with a scoped argument$", { assertEquals(2, localInt + 1) }) | ||
|
||
Given("^I will give you (\\d+) and ([\\d\\.]+) and (\\w+) and (\\d+)$") { a: Int, b: Float, c: String, d: Int -> | ||
assertEquals(1, a) | ||
assertEquals(2.2f, b) | ||
assertEquals("three", c) | ||
assertEquals(4, d) | ||
} | ||
} | ||
|
||
class Person { | ||
internal var first: String? = null | ||
internal var last: String? = null | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
kotlin-java8/src/test/kotlin/cucumber/runtime/kotlin/test/RunCukesTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package cucumber.runtime.kotlin.test | ||
|
||
import cucumber.api.junit.Cucumber | ||
import org.junit.runner.RunWith | ||
|
||
@RunWith(Cucumber::class) | ||
class RunCukesTest { | ||
} |
25 changes: 25 additions & 0 deletions
25
kotlin-java8/src/test/resources/cucumber/runtime/kotlin/test/kotlin.feature
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
Feature: Kotlin | ||
|
||
Scenario: use the API with Java8 style | ||
Given I have 42 cukes in my belly | ||
Then I really have 42 cukes in my belly | ||
|
||
Scenario: another scenario which should have isolated state | ||
Given I have 42 cukes in my belly | ||
And something that isn't defined | ||
|
||
Scenario: Parameterless lambdas | ||
Given A statement with a simple match | ||
Given A statement with a scoped argument | ||
|
||
Scenario: I can use body expressions | ||
Given A statement with a body expression | ||
|
||
Scenario: Multi-param lambdas | ||
Given I will give you 1 and 2.2 and three and 4 | ||
|
||
Scenario: use a table | ||
Given this data table: | ||
| first | last | | ||
| Aslak | Hellesøy | | ||
| Donald | Duck | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters