From 271b1a30e66f350a2a9fabac43f7467dab83a5aa Mon Sep 17 00:00:00 2001 From: Jitendra_Singh2 Date: Fri, 16 May 2025 23:07:07 +0530 Subject: [PATCH 01/24] first commit Signed-off-by: Jitendra_Singh2 --- examples/calculator-kotlin-testng/.gitignore | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 examples/calculator-kotlin-testng/.gitignore diff --git a/examples/calculator-kotlin-testng/.gitignore b/examples/calculator-kotlin-testng/.gitignore new file mode 100644 index 0000000000..dae4369610 --- /dev/null +++ b/examples/calculator-kotlin-testng/.gitignore @@ -0,0 +1,4 @@ +/.settings +/.classpath +/.project +/test-output/ From 8ca70be8c86b94a7ee6f4c5105f966ee897ca098 Mon Sep 17 00:00:00 2001 From: Jitendra_Singh2 Date: Fri, 16 May 2025 23:08:59 +0530 Subject: [PATCH 02/24] add examples for Kotlin Signed-off-by: Jitendra_Singh2 --- examples/calculator-kotlin-testng/pom.xml | 86 +++++++++++++ .../examples/calaculator/RpnCalculator.kt | 29 +++++ .../examples/calculator/RunCucumberTest.kt | 19 +++ .../calculator/ShoppingStepDefinitions.kt | 56 +++++++++ .../calculator/basic_arithmetic.feature | 35 ++++++ .../calculator/date_calculator.feature | 8 ++ .../examples/calculator/shopping.feature | 11 ++ examples/pom.xml | 118 +++++++++--------- 8 files changed, 301 insertions(+), 61 deletions(-) create mode 100644 examples/calculator-kotlin-testng/pom.xml create mode 100644 examples/calculator-kotlin-testng/src/main/kotlin/io/cucumber/examples/calaculator/RpnCalculator.kt create mode 100644 examples/calculator-kotlin-testng/src/test/kotlin/io/cucumber/examples/calculator/RunCucumberTest.kt create mode 100644 examples/calculator-kotlin-testng/src/test/kotlin/io/cucumber/examples/calculator/ShoppingStepDefinitions.kt create mode 100644 examples/calculator-kotlin-testng/src/test/resources/io/cucumber/examples/calculator/basic_arithmetic.feature create mode 100644 examples/calculator-kotlin-testng/src/test/resources/io/cucumber/examples/calculator/date_calculator.feature create mode 100644 examples/calculator-kotlin-testng/src/test/resources/io/cucumber/examples/calculator/shopping.feature diff --git a/examples/calculator-kotlin-testng/pom.xml b/examples/calculator-kotlin-testng/pom.xml new file mode 100644 index 0000000000..84313d0101 --- /dev/null +++ b/examples/calculator-kotlin-testng/pom.xml @@ -0,0 +1,86 @@ + + + + 4.0.0 + + + examples + io.cucumber + 7.22.3-SNAPSHOT + + + calculator-kotlin-testng + 1.0-SNAPSHOT + jar + + Kotlin Examples: Calculator - Annotations - TestNG + + + UTF-8 + 1.9.0 + official + 4.13.1 + + + + + org.jetbrains.kotlin + kotlin-stdlib + ${kotlin.version} + + + org.jetbrains.kotlin + kotlin-test-junit + ${kotlin.version} + test + + + junit + junit + ${junit.version} + test + + + io.cucumber + cucumber-java + 7.22.3-SNAPSHOT + test + + + io.cucumber + cucumber-testng + 7.22.3-SNAPSHOT + test + + + + + src/main/kotlin + src/test/kotlin + + + + org.jetbrains.kotlin + kotlin-maven-plugin + ${kotlin.version} + + + compile + compile + + compile + + + + test-compile + test-compile + + test-compile + + + + + + + + diff --git a/examples/calculator-kotlin-testng/src/main/kotlin/io/cucumber/examples/calaculator/RpnCalculator.kt b/examples/calculator-kotlin-testng/src/main/kotlin/io/cucumber/examples/calaculator/RpnCalculator.kt new file mode 100644 index 0000000000..d6433bbde2 --- /dev/null +++ b/examples/calculator-kotlin-testng/src/main/kotlin/io/cucumber/examples/calaculator/RpnCalculator.kt @@ -0,0 +1,29 @@ +package io.cucumber.examples.calaculator + +class RpnCalculator { + private val stack: ArrayDeque = ArrayDeque() + + private val OPS = setOf("+", "-", "*", "/") + + fun push(arg: Any) { + if (arg in OPS) { + val y = stack.removeLast() + val x = if (stack.isEmpty()) 0 else stack.removeLast() + val valResult = when (arg) { + "-" -> x.toDouble() - y.toDouble() + "+" -> x.toDouble() + y.toDouble() + "*" -> x.toDouble() * y.toDouble() + "/" -> x.toDouble() / y.toDouble() + else -> throw IllegalArgumentException("Unknown operation $arg") + } + push(valResult) + } else { + stack.addLast(arg as Number) + } + } + + fun peek(): Number? = stack.lastOrNull() + + fun clear() = stack.clear() +} + diff --git a/examples/calculator-kotlin-testng/src/test/kotlin/io/cucumber/examples/calculator/RunCucumberTest.kt b/examples/calculator-kotlin-testng/src/test/kotlin/io/cucumber/examples/calculator/RunCucumberTest.kt new file mode 100644 index 0000000000..b2e2485456 --- /dev/null +++ b/examples/calculator-kotlin-testng/src/test/kotlin/io/cucumber/examples/calculator/RunCucumberTest.kt @@ -0,0 +1,19 @@ +package io.cucumber.examples.calculator + +import io.cucumber.testng.AbstractTestNGCucumberTests +import io.cucumber.testng.CucumberOptions +import org.testng.annotations.DataProvider + + +@CucumberOptions( + plugin = ["html:target/results.html"], +// tags = "@shopping" +) +class RunCucumberTest : AbstractTestNGCucumberTests() { + + @DataProvider + override fun scenarios(): Array> { + return super.scenarios() + } + +} diff --git a/examples/calculator-kotlin-testng/src/test/kotlin/io/cucumber/examples/calculator/ShoppingStepDefinitions.kt b/examples/calculator-kotlin-testng/src/test/kotlin/io/cucumber/examples/calculator/ShoppingStepDefinitions.kt new file mode 100644 index 0000000000..adc5060d1b --- /dev/null +++ b/examples/calculator-kotlin-testng/src/test/kotlin/io/cucumber/examples/calculator/ShoppingStepDefinitions.kt @@ -0,0 +1,56 @@ +package io.cucumber.examples.calculator + +import io.cucumber.datatable.DataTable +import io.cucumber.examples.calaculator.RpnCalculator +import io.cucumber.java.DataTableType +import io.cucumber.java.en.Given +import io.cucumber.java.en.Then +import io.cucumber.java.en.When +import kotlin.test.assertEquals + +class ShoppingStepDefinitions { + private val rpnCalculator = RpnCalculator() + private val groceryList = mutableListOf() + + + + @Given("the following groceries") + fun givenTheFollowingGroceries(grocery: DataTable){ + val groceries: List = grocery.asList(Grocery::class.java) + groceryList.addAll(groceries) + for (gro in groceries){ + rpnCalculator.push(gro.price.value) + rpnCalculator.push("+") + } + } + + @When("I pay {int}") + fun whenIPay(amount: Int) { + rpnCalculator.push(amount) + rpnCalculator.push("-") + } + + @Then("my change should be {int}") + fun myChangeShouldBe(change: Int) { + rpnCalculator.peek()?.let { assertEquals(change, -it.toInt()) } + } + + @DataTableType + fun groceryEntry(entry: Map): Grocery { + val name = entry["name"] ?: error("Missing name") + val price = Price.fromString(entry["price"] ?: error("Missing price")) + return Grocery(name, price) + } + + data class Grocery(val name: String, val price: Price) + + @JvmInline + value class Price(val value: Int) { + companion object { + fun fromString(value: String): Price { + return Price(value.toInt()) + } + } + } + +} diff --git a/examples/calculator-kotlin-testng/src/test/resources/io/cucumber/examples/calculator/basic_arithmetic.feature b/examples/calculator-kotlin-testng/src/test/resources/io/cucumber/examples/calculator/basic_arithmetic.feature new file mode 100644 index 0000000000..79b252a23d --- /dev/null +++ b/examples/calculator-kotlin-testng/src/test/resources/io/cucumber/examples/calculator/basic_arithmetic.feature @@ -0,0 +1,35 @@ +@foo +Feature: Basic Arithmetic + + Background: A Calculator + Given a calculator I just turned on + + Scenario: Addition + # Try to change one of the values below to provoke a failure + When I add 4 and 5 + Then the result is 9 + + Scenario: Another Addition + # Try to change one of the values below to provoke a failure + When I add 4 and 7 + Then the result is 11 + + Scenario Outline: Many additions + Given the previous entries: + | first | second | operation | + | 1 | 1 | + | + | 2 | 1 | + | + When I press + + And I add and + And I press + + Then the result is + + Examples: Single digits + | a | b | c | + | 1 | 2 | 8 | + | 2 | 3 | 10 | + + Examples: Double digits + | a | b | c | + | 10 | 20 | 35 | + | 20 | 30 | 55 | diff --git a/examples/calculator-kotlin-testng/src/test/resources/io/cucumber/examples/calculator/date_calculator.feature b/examples/calculator-kotlin-testng/src/test/resources/io/cucumber/examples/calculator/date_calculator.feature new file mode 100644 index 0000000000..b5295ccbd1 --- /dev/null +++ b/examples/calculator-kotlin-testng/src/test/resources/io/cucumber/examples/calculator/date_calculator.feature @@ -0,0 +1,8 @@ +Feature: Dates with different date formats + This feature shows you can have different date formats, as long as you annotate the + corresponding step definition method accordingly. + + Scenario: Determine past date + Given today is 2011-01-20 + When I ask if Jan 19, 2011 is in the past + Then the result should be yes diff --git a/examples/calculator-kotlin-testng/src/test/resources/io/cucumber/examples/calculator/shopping.feature b/examples/calculator-kotlin-testng/src/test/resources/io/cucumber/examples/calculator/shopping.feature new file mode 100644 index 0000000000..87089ce083 --- /dev/null +++ b/examples/calculator-kotlin-testng/src/test/resources/io/cucumber/examples/calculator/shopping.feature @@ -0,0 +1,11 @@ +Feature: Shopping + + @shopping + Scenario: Give correct change + Given the following groceries + | name | price | + | milk | 9 | + | bread | 7 | + | soap | 5 | + When I pay 25 + Then my change should be 4 diff --git a/examples/pom.xml b/examples/pom.xml index dc705ed806..dc3d423f80 100644 --- a/examples/pom.xml +++ b/examples/pom.xml @@ -1,62 +1,58 @@ - - 4.0.0 - - - io.cucumber - cucumber-jvm - 7.22.3-SNAPSHOT - - - examples - pom - Examples - - - calculator-java8-cli - calculator-java-cli - calculator-java-junit4 - calculator-java-junit5 - calculator-java-testng - spring-java-junit5 - wicket-java-junit4 - - - - - - - maven-jar-plugin - - true - - - - maven-install-plugin - - true - - - - maven-javadoc-plugin - - true - - - - maven-deploy-plugin - - true - - - - org.revapi - revapi-maven-plugin - - true - - - - - + + 4.0.0 + + io.cucumber + cucumber-jvm + 7.22.3-SNAPSHOT + + examples + pom + Examples + + calculator-java8-cli + calculator-java-cli + calculator-java-junit4 + calculator-java-junit5 + calculator-java-testng + spring-java-junit5 + wicket-java-junit4 + calculator-kotlin-testng + + + + + + maven-jar-plugin + + true + + + + maven-install-plugin + + true + + + + maven-javadoc-plugin + + true + + + + maven-deploy-plugin + + true + + + + org.revapi + revapi-maven-plugin + + true + + + + + - From 63119921b987ae7b8997526b95e2654e68ca991e Mon Sep 17 00:00:00 2001 From: Jitendra_Singh2 Date: Sat, 17 May 2025 04:11:01 +0530 Subject: [PATCH 03/24] add examples for Kotlin date_calculator.feature Signed-off-by: Jitendra_Singh2 --- .../io/cucumber/examples/calculator/date_calculator.feature | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/calculator-kotlin-testng/src/test/resources/io/cucumber/examples/calculator/date_calculator.feature b/examples/calculator-kotlin-testng/src/test/resources/io/cucumber/examples/calculator/date_calculator.feature index b5295ccbd1..ed665e833d 100644 --- a/examples/calculator-kotlin-testng/src/test/resources/io/cucumber/examples/calculator/date_calculator.feature +++ b/examples/calculator-kotlin-testng/src/test/resources/io/cucumber/examples/calculator/date_calculator.feature @@ -2,7 +2,8 @@ Feature: Dates with different date formats This feature shows you can have different date formats, as long as you annotate the corresponding step definition method accordingly. + @date Scenario: Determine past date Given today is 2011-01-20 When I ask if Jan 19, 2011 is in the past - Then the result should be yes + Then the result should be "yes" From 2cbc758bdd57888323ed2d8564672540944062ed Mon Sep 17 00:00:00 2001 From: Jitendra_Singh2 Date: Sat, 17 May 2025 04:25:02 +0530 Subject: [PATCH 04/24] add implementations for Kotlin date_calculator.feature Signed-off-by: Jitendra_Singh2 --- .../examples/calaculator/DateCalculator.kt | 12 +++++++ .../calculator/DateStepDefinitions.kt | 36 +++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 examples/calculator-kotlin-testng/src/main/kotlin/io/cucumber/examples/calaculator/DateCalculator.kt create mode 100644 examples/calculator-kotlin-testng/src/test/kotlin/io/cucumber/examples/calculator/DateStepDefinitions.kt diff --git a/examples/calculator-kotlin-testng/src/main/kotlin/io/cucumber/examples/calaculator/DateCalculator.kt b/examples/calculator-kotlin-testng/src/main/kotlin/io/cucumber/examples/calaculator/DateCalculator.kt new file mode 100644 index 0000000000..5f3ec14be0 --- /dev/null +++ b/examples/calculator-kotlin-testng/src/main/kotlin/io/cucumber/examples/calaculator/DateCalculator.kt @@ -0,0 +1,12 @@ +package io.cucumber.examples.calaculator + +import java.time.LocalDate +import java.util.* + +class DateCalculator(private val now: LocalDate) { + + fun isDateInThePast(date: LocalDate): String { + return if (date.isBefore(now)) "yes" else "no" + } +} + diff --git a/examples/calculator-kotlin-testng/src/test/kotlin/io/cucumber/examples/calculator/DateStepDefinitions.kt b/examples/calculator-kotlin-testng/src/test/kotlin/io/cucumber/examples/calculator/DateStepDefinitions.kt new file mode 100644 index 0000000000..df99b40f09 --- /dev/null +++ b/examples/calculator-kotlin-testng/src/test/kotlin/io/cucumber/examples/calculator/DateStepDefinitions.kt @@ -0,0 +1,36 @@ +package io.cucumber.examples.calculator + +import io.cucumber.examples.calaculator.DateCalculator +import io.cucumber.java.en.Given +import io.cucumber.java.en.Then +import io.cucumber.java.en.When +import java.time.LocalDate +import java.time.format.DateTimeFormatter +import java.util.* +import kotlin.test.assertEquals + +class DateStepDefinitions { + + private lateinit var result: String + + private lateinit var calculator: DateCalculator + + + @Given("today is {}") + fun todayIs(date: String) { + val date1 = LocalDate.parse(date) + calculator = DateCalculator(now = date1) + } + + @When("I ask if {} is in the past") + fun iAskIfDateIsInPast(date: String) { + val formatter: DateTimeFormatter = DateTimeFormatter.ofPattern("MMM d, yyyy", Locale.ENGLISH) + val date2 = LocalDate.parse(date,formatter) + result = calculator.isDateInThePast(date2) + } + + @Then("the result should be {string}") + fun theResultShouldBeYes(answer: String) { + assertEquals(answer, result) + } +} From 27d061be21cbf2bf86e6296e3d368aadbcbc1dea Mon Sep 17 00:00:00 2001 From: Jitendra_Singh2 Date: Sat, 17 May 2025 04:26:05 +0530 Subject: [PATCH 05/24] remove tag from RunCucumberTest.kt Signed-off-by: Jitendra_Singh2 --- .../kotlin/io/cucumber/examples/calculator/RunCucumberTest.kt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/examples/calculator-kotlin-testng/src/test/kotlin/io/cucumber/examples/calculator/RunCucumberTest.kt b/examples/calculator-kotlin-testng/src/test/kotlin/io/cucumber/examples/calculator/RunCucumberTest.kt index b2e2485456..88c8c7bfef 100644 --- a/examples/calculator-kotlin-testng/src/test/kotlin/io/cucumber/examples/calculator/RunCucumberTest.kt +++ b/examples/calculator-kotlin-testng/src/test/kotlin/io/cucumber/examples/calculator/RunCucumberTest.kt @@ -6,8 +6,7 @@ import org.testng.annotations.DataProvider @CucumberOptions( - plugin = ["html:target/results.html"], -// tags = "@shopping" + plugin = ["html:target/results.html"] ) class RunCucumberTest : AbstractTestNGCucumberTests() { From 785035ca17cb83f6102ca55eb82eafdb19714d37 Mon Sep 17 00:00:00 2001 From: Jitendra Singh2 <138148209+jit3pam@users.noreply.github.com> Date: Mon, 19 May 2025 16:17:44 +0530 Subject: [PATCH 06/24] Update examples/calculator-kotlin-testng/pom.xml Co-authored-by: M.P. Korstanje --- examples/calculator-kotlin-testng/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/calculator-kotlin-testng/pom.xml b/examples/calculator-kotlin-testng/pom.xml index 84313d0101..1df7604c40 100644 --- a/examples/calculator-kotlin-testng/pom.xml +++ b/examples/calculator-kotlin-testng/pom.xml @@ -13,7 +13,7 @@ 1.0-SNAPSHOT jar - Kotlin Examples: Calculator - Annotations - TestNG + Examples: Calculator - Kotlin - Annotations - TestNG UTF-8 From 326c3c66b28f1948b1e01e50a18b79fce09908f4 Mon Sep 17 00:00:00 2001 From: Jitendra_Singh2 Date: Tue, 20 May 2025 03:22:52 +0530 Subject: [PATCH 07/24] restore pom.xml in examples Signed-off-by: Jitendra_Singh2 --- examples/pom.xml | 118 ++++++++++++++++++++++++----------------------- 1 file changed, 61 insertions(+), 57 deletions(-) diff --git a/examples/pom.xml b/examples/pom.xml index dc3d423f80..1185568465 100644 --- a/examples/pom.xml +++ b/examples/pom.xml @@ -1,58 +1,62 @@ - - 4.0.0 - - io.cucumber - cucumber-jvm - 7.22.3-SNAPSHOT - - examples - pom - Examples - - calculator-java8-cli - calculator-java-cli - calculator-java-junit4 - calculator-java-junit5 - calculator-java-testng - spring-java-junit5 - wicket-java-junit4 - calculator-kotlin-testng - - - - - - maven-jar-plugin - - true - - - - maven-install-plugin - - true - - - - maven-javadoc-plugin - - true - - - - maven-deploy-plugin - - true - - - - org.revapi - revapi-maven-plugin - - true - - - - - + + 4.0.0 + + + io.cucumber + cucumber-jvm + 7.22.3-SNAPSHOT + + + examples + pom + Examples + + + calculator-java8-cli + calculator-java-cli + calculator-java-junit4 + calculator-java-junit5 + calculator-java-testng + spring-java-junit5 + wicket-java-junit4 + + + + + + + maven-jar-plugin + + true + + + + maven-install-plugin + + true + + + + maven-javadoc-plugin + + true + + + + maven-deploy-plugin + + true + + + + org.revapi + revapi-maven-plugin + + true + + + + + + From 698675f4f0665d9f2d3f719dabf5cf3354a92c14 Mon Sep 17 00:00:00 2001 From: Jitendra_Singh2 Date: Wed, 21 May 2025 10:06:36 +0530 Subject: [PATCH 08/24] update examples to use junit5 Signed-off-by: Jitendra_Singh2 --- .../.gitignore | 0 examples/calculator-kotlin-junit5/pom.xml | 180 ++++++++++++++++++ .../examples/calaculator/DateCalculator.kt | 0 .../examples/calaculator/RpnCalculator.kt | 0 .../calculator/DateStepDefinitions.kt | 0 .../calculator/RunCucumberKotlinTest.kt | 12 ++ .../calculator/ShoppingStepDefinitions.kt | 0 .../calculator/date_calculator.feature | 0 .../examples/calculator/shopping.feature | 0 examples/calculator-kotlin-testng/pom.xml | 86 --------- .../examples/calculator/RunCucumberTest.kt | 18 -- .../calculator/basic_arithmetic.feature | 35 ---- examples/pom.xml | 1 + 13 files changed, 193 insertions(+), 139 deletions(-) rename examples/{calculator-kotlin-testng => calculator-kotlin-junit5}/.gitignore (100%) create mode 100644 examples/calculator-kotlin-junit5/pom.xml rename examples/{calculator-kotlin-testng => calculator-kotlin-junit5}/src/main/kotlin/io/cucumber/examples/calaculator/DateCalculator.kt (100%) rename examples/{calculator-kotlin-testng => calculator-kotlin-junit5}/src/main/kotlin/io/cucumber/examples/calaculator/RpnCalculator.kt (100%) rename examples/{calculator-kotlin-testng => calculator-kotlin-junit5}/src/test/kotlin/io/cucumber/examples/calculator/DateStepDefinitions.kt (100%) create mode 100644 examples/calculator-kotlin-junit5/src/test/kotlin/io/cucumber/examples/calculator/RunCucumberKotlinTest.kt rename examples/{calculator-kotlin-testng => calculator-kotlin-junit5}/src/test/kotlin/io/cucumber/examples/calculator/ShoppingStepDefinitions.kt (100%) rename examples/{calculator-kotlin-testng => calculator-kotlin-junit5}/src/test/resources/io/cucumber/examples/calculator/date_calculator.feature (100%) rename examples/{calculator-kotlin-testng => calculator-kotlin-junit5}/src/test/resources/io/cucumber/examples/calculator/shopping.feature (100%) delete mode 100644 examples/calculator-kotlin-testng/pom.xml delete mode 100644 examples/calculator-kotlin-testng/src/test/kotlin/io/cucumber/examples/calculator/RunCucumberTest.kt delete mode 100644 examples/calculator-kotlin-testng/src/test/resources/io/cucumber/examples/calculator/basic_arithmetic.feature diff --git a/examples/calculator-kotlin-testng/.gitignore b/examples/calculator-kotlin-junit5/.gitignore similarity index 100% rename from examples/calculator-kotlin-testng/.gitignore rename to examples/calculator-kotlin-junit5/.gitignore diff --git a/examples/calculator-kotlin-junit5/pom.xml b/examples/calculator-kotlin-junit5/pom.xml new file mode 100644 index 0000000000..d60a404426 --- /dev/null +++ b/examples/calculator-kotlin-junit5/pom.xml @@ -0,0 +1,180 @@ + + + + 4.0.0 + + + examples + io.cucumber + 7.22.3-SNAPSHOT + + + calculator-kotlin-junit5 + jar + + Examples: Calculator - Kotlin - Annotations - TestNG + + + UTF-8 + 1.9.0 + official + 5.12.2 + io.cucumber.examples.calculator + + + + + + io.cucumber + cucumber-bom + ${project.version} + pom + import + + + org.junit + junit-bom + ${junit-jupiter.version} + pom + import + + + + + + + org.jetbrains.kotlin + kotlin-stdlib + ${kotlin.version} + + + org.jetbrains.kotlin + kotlin-test-junit + ${kotlin.version} + test + + + io.cucumber + cucumber-junit-platform-engine + test + + + org.junit.platform + junit-platform-suite + 1.12.2 + test + + + org.junit.jupiter + junit-jupiter + 5.12.2 + test + + + org.junit.jupiter + junit-jupiter-api + ${junit-jupiter.version} + test + + + org.junit.jupiter + junit-jupiter-engine + ${junit-jupiter.version} + test + + + org.junit.platform + junit-platform-console + test + + + io.cucumber + cucumber-java + 7.22.3-SNAPSHOT + test + + + io.cucumber + cucumber-testng + 7.22.3-SNAPSHOT + test + + + + + src/main/kotlin + src/test/kotlin + + + + org.jetbrains.kotlin + kotlin-maven-plugin + ${kotlin.version} + + + compile + compile + + compile + + + + test-compile + test-compile + + test-compile + + + + + + maven-failsafe-plugin + 3.5.3 + + + org.apache.maven.plugins + maven-surefire-plugin + + + + + cucumber.junit-platform.naming-strategy=long + + + + + + org.apache.maven.plugins + maven-antrun-plugin + + + + cli-test + test + + run + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/calculator-kotlin-testng/src/main/kotlin/io/cucumber/examples/calaculator/DateCalculator.kt b/examples/calculator-kotlin-junit5/src/main/kotlin/io/cucumber/examples/calaculator/DateCalculator.kt similarity index 100% rename from examples/calculator-kotlin-testng/src/main/kotlin/io/cucumber/examples/calaculator/DateCalculator.kt rename to examples/calculator-kotlin-junit5/src/main/kotlin/io/cucumber/examples/calaculator/DateCalculator.kt diff --git a/examples/calculator-kotlin-testng/src/main/kotlin/io/cucumber/examples/calaculator/RpnCalculator.kt b/examples/calculator-kotlin-junit5/src/main/kotlin/io/cucumber/examples/calaculator/RpnCalculator.kt similarity index 100% rename from examples/calculator-kotlin-testng/src/main/kotlin/io/cucumber/examples/calaculator/RpnCalculator.kt rename to examples/calculator-kotlin-junit5/src/main/kotlin/io/cucumber/examples/calaculator/RpnCalculator.kt diff --git a/examples/calculator-kotlin-testng/src/test/kotlin/io/cucumber/examples/calculator/DateStepDefinitions.kt b/examples/calculator-kotlin-junit5/src/test/kotlin/io/cucumber/examples/calculator/DateStepDefinitions.kt similarity index 100% rename from examples/calculator-kotlin-testng/src/test/kotlin/io/cucumber/examples/calculator/DateStepDefinitions.kt rename to examples/calculator-kotlin-junit5/src/test/kotlin/io/cucumber/examples/calculator/DateStepDefinitions.kt diff --git a/examples/calculator-kotlin-junit5/src/test/kotlin/io/cucumber/examples/calculator/RunCucumberKotlinTest.kt b/examples/calculator-kotlin-junit5/src/test/kotlin/io/cucumber/examples/calculator/RunCucumberKotlinTest.kt new file mode 100644 index 0000000000..5bc6ff3185 --- /dev/null +++ b/examples/calculator-kotlin-junit5/src/test/kotlin/io/cucumber/examples/calculator/RunCucumberKotlinTest.kt @@ -0,0 +1,12 @@ +package io.cucumber.examples.calculator + +import io.cucumber.junit.platform.engine.Constants +import org.junit.platform.suite.api.* + + +@Suite +@IncludeEngines("cucumber") +@SelectPackages("io.cucumber.examples.calculator") +@ConfigurationParameter(key = Constants.GLUE_PROPERTY_NAME, value = "io.cucumber.examples.calculator") +@SelectClasspathResource("io.cucumber.examples.calculator") +class RunCucumberKotlinTest diff --git a/examples/calculator-kotlin-testng/src/test/kotlin/io/cucumber/examples/calculator/ShoppingStepDefinitions.kt b/examples/calculator-kotlin-junit5/src/test/kotlin/io/cucumber/examples/calculator/ShoppingStepDefinitions.kt similarity index 100% rename from examples/calculator-kotlin-testng/src/test/kotlin/io/cucumber/examples/calculator/ShoppingStepDefinitions.kt rename to examples/calculator-kotlin-junit5/src/test/kotlin/io/cucumber/examples/calculator/ShoppingStepDefinitions.kt diff --git a/examples/calculator-kotlin-testng/src/test/resources/io/cucumber/examples/calculator/date_calculator.feature b/examples/calculator-kotlin-junit5/src/test/resources/io/cucumber/examples/calculator/date_calculator.feature similarity index 100% rename from examples/calculator-kotlin-testng/src/test/resources/io/cucumber/examples/calculator/date_calculator.feature rename to examples/calculator-kotlin-junit5/src/test/resources/io/cucumber/examples/calculator/date_calculator.feature diff --git a/examples/calculator-kotlin-testng/src/test/resources/io/cucumber/examples/calculator/shopping.feature b/examples/calculator-kotlin-junit5/src/test/resources/io/cucumber/examples/calculator/shopping.feature similarity index 100% rename from examples/calculator-kotlin-testng/src/test/resources/io/cucumber/examples/calculator/shopping.feature rename to examples/calculator-kotlin-junit5/src/test/resources/io/cucumber/examples/calculator/shopping.feature diff --git a/examples/calculator-kotlin-testng/pom.xml b/examples/calculator-kotlin-testng/pom.xml deleted file mode 100644 index 1df7604c40..0000000000 --- a/examples/calculator-kotlin-testng/pom.xml +++ /dev/null @@ -1,86 +0,0 @@ - - - - 4.0.0 - - - examples - io.cucumber - 7.22.3-SNAPSHOT - - - calculator-kotlin-testng - 1.0-SNAPSHOT - jar - - Examples: Calculator - Kotlin - Annotations - TestNG - - - UTF-8 - 1.9.0 - official - 4.13.1 - - - - - org.jetbrains.kotlin - kotlin-stdlib - ${kotlin.version} - - - org.jetbrains.kotlin - kotlin-test-junit - ${kotlin.version} - test - - - junit - junit - ${junit.version} - test - - - io.cucumber - cucumber-java - 7.22.3-SNAPSHOT - test - - - io.cucumber - cucumber-testng - 7.22.3-SNAPSHOT - test - - - - - src/main/kotlin - src/test/kotlin - - - - org.jetbrains.kotlin - kotlin-maven-plugin - ${kotlin.version} - - - compile - compile - - compile - - - - test-compile - test-compile - - test-compile - - - - - - - - diff --git a/examples/calculator-kotlin-testng/src/test/kotlin/io/cucumber/examples/calculator/RunCucumberTest.kt b/examples/calculator-kotlin-testng/src/test/kotlin/io/cucumber/examples/calculator/RunCucumberTest.kt deleted file mode 100644 index 88c8c7bfef..0000000000 --- a/examples/calculator-kotlin-testng/src/test/kotlin/io/cucumber/examples/calculator/RunCucumberTest.kt +++ /dev/null @@ -1,18 +0,0 @@ -package io.cucumber.examples.calculator - -import io.cucumber.testng.AbstractTestNGCucumberTests -import io.cucumber.testng.CucumberOptions -import org.testng.annotations.DataProvider - - -@CucumberOptions( - plugin = ["html:target/results.html"] -) -class RunCucumberTest : AbstractTestNGCucumberTests() { - - @DataProvider - override fun scenarios(): Array> { - return super.scenarios() - } - -} diff --git a/examples/calculator-kotlin-testng/src/test/resources/io/cucumber/examples/calculator/basic_arithmetic.feature b/examples/calculator-kotlin-testng/src/test/resources/io/cucumber/examples/calculator/basic_arithmetic.feature deleted file mode 100644 index 79b252a23d..0000000000 --- a/examples/calculator-kotlin-testng/src/test/resources/io/cucumber/examples/calculator/basic_arithmetic.feature +++ /dev/null @@ -1,35 +0,0 @@ -@foo -Feature: Basic Arithmetic - - Background: A Calculator - Given a calculator I just turned on - - Scenario: Addition - # Try to change one of the values below to provoke a failure - When I add 4 and 5 - Then the result is 9 - - Scenario: Another Addition - # Try to change one of the values below to provoke a failure - When I add 4 and 7 - Then the result is 11 - - Scenario Outline: Many additions - Given the previous entries: - | first | second | operation | - | 1 | 1 | + | - | 2 | 1 | + | - When I press + - And I add and - And I press + - Then the result is - - Examples: Single digits - | a | b | c | - | 1 | 2 | 8 | - | 2 | 3 | 10 | - - Examples: Double digits - | a | b | c | - | 10 | 20 | 35 | - | 20 | 30 | 55 | diff --git a/examples/pom.xml b/examples/pom.xml index 1185568465..6b75b50096 100644 --- a/examples/pom.xml +++ b/examples/pom.xml @@ -19,6 +19,7 @@ calculator-java-testng spring-java-junit5 wicket-java-junit4 + calculator-kotlin-junit5 From 194ab0231b38e4f9ff508784bbe5ead09306c73a Mon Sep 17 00:00:00 2001 From: Jitendra_Singh2 Date: Wed, 21 May 2025 11:57:04 +0530 Subject: [PATCH 09/24] update dependencies in pom.xml Signed-off-by: Jitendra_Singh2 --- examples/calculator-kotlin-junit5/pom.xml | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/examples/calculator-kotlin-junit5/pom.xml b/examples/calculator-kotlin-junit5/pom.xml index d60a404426..161309a667 100644 --- a/examples/calculator-kotlin-junit5/pom.xml +++ b/examples/calculator-kotlin-junit5/pom.xml @@ -12,7 +12,7 @@ calculator-kotlin-junit5 jar - Examples: Calculator - Kotlin - Annotations - TestNG + Examples: Calculator - Kotlin - Annotations - Junit 5 UTF-8 @@ -67,7 +67,7 @@ org.junit.jupiter junit-jupiter - 5.12.2 + ${junit-jupiter.version} test @@ -90,15 +90,9 @@ io.cucumber cucumber-java - 7.22.3-SNAPSHOT - test - - - io.cucumber - cucumber-testng - 7.22.3-SNAPSHOT test + From 7684f62c1f6a31669f0a440be55a5ef5658e52c8 Mon Sep 17 00:00:00 2001 From: Jitendra_Singh2 Date: Wed, 21 May 2025 13:36:54 +0530 Subject: [PATCH 10/24] update dependencies in pom.xml, and change .* imports to explicit imports Signed-off-by: Jitendra_Singh2 --- examples/calculator-kotlin-junit5/pom.xml | 10 +++++----- .../examples/calculator/DateStepDefinitions.kt | 2 +- .../examples/calculator/RunCucumberKotlinTest.kt | 6 +++++- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/examples/calculator-kotlin-junit5/pom.xml b/examples/calculator-kotlin-junit5/pom.xml index 161309a667..b01394af3f 100644 --- a/examples/calculator-kotlin-junit5/pom.xml +++ b/examples/calculator-kotlin-junit5/pom.xml @@ -42,6 +42,11 @@ + + io.cucumber + cucumber-java + test + org.jetbrains.kotlin kotlin-stdlib @@ -87,11 +92,6 @@ junit-platform-console test - - io.cucumber - cucumber-java - test - diff --git a/examples/calculator-kotlin-junit5/src/test/kotlin/io/cucumber/examples/calculator/DateStepDefinitions.kt b/examples/calculator-kotlin-junit5/src/test/kotlin/io/cucumber/examples/calculator/DateStepDefinitions.kt index df99b40f09..538521121b 100644 --- a/examples/calculator-kotlin-junit5/src/test/kotlin/io/cucumber/examples/calculator/DateStepDefinitions.kt +++ b/examples/calculator-kotlin-junit5/src/test/kotlin/io/cucumber/examples/calculator/DateStepDefinitions.kt @@ -6,7 +6,7 @@ import io.cucumber.java.en.Then import io.cucumber.java.en.When import java.time.LocalDate import java.time.format.DateTimeFormatter -import java.util.* +import java.util.Locale import kotlin.test.assertEquals class DateStepDefinitions { diff --git a/examples/calculator-kotlin-junit5/src/test/kotlin/io/cucumber/examples/calculator/RunCucumberKotlinTest.kt b/examples/calculator-kotlin-junit5/src/test/kotlin/io/cucumber/examples/calculator/RunCucumberKotlinTest.kt index 5bc6ff3185..b82457b0e0 100644 --- a/examples/calculator-kotlin-junit5/src/test/kotlin/io/cucumber/examples/calculator/RunCucumberKotlinTest.kt +++ b/examples/calculator-kotlin-junit5/src/test/kotlin/io/cucumber/examples/calculator/RunCucumberKotlinTest.kt @@ -1,7 +1,11 @@ package io.cucumber.examples.calculator import io.cucumber.junit.platform.engine.Constants -import org.junit.platform.suite.api.* +import org.junit.platform.suite.api.Suite +import org.junit.platform.suite.api.IncludeEngines +import org.junit.platform.suite.api.SelectPackages +import org.junit.platform.suite.api.ConfigurationParameter +import org.junit.platform.suite.api.SelectClasspathResource @Suite From ca7df3cc1732a831b896e818b9c16226e176fbe3 Mon Sep 17 00:00:00 2001 From: Jitendra_Singh2 Date: Fri, 16 May 2025 23:07:07 +0530 Subject: [PATCH 11/24] first commit Signed-off-by: Jitendra_Singh2 --- examples/calculator-kotlin-testng/.gitignore | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 examples/calculator-kotlin-testng/.gitignore diff --git a/examples/calculator-kotlin-testng/.gitignore b/examples/calculator-kotlin-testng/.gitignore new file mode 100644 index 0000000000..dae4369610 --- /dev/null +++ b/examples/calculator-kotlin-testng/.gitignore @@ -0,0 +1,4 @@ +/.settings +/.classpath +/.project +/test-output/ From 0136a4432e18664b2660cb6db62192bf2b9cca44 Mon Sep 17 00:00:00 2001 From: Jitendra_Singh2 Date: Fri, 16 May 2025 23:08:59 +0530 Subject: [PATCH 12/24] add examples for Kotlin Signed-off-by: Jitendra_Singh2 --- examples/calculator-kotlin-testng/pom.xml | 86 +++++++++++++ .../examples/calaculator/RpnCalculator.kt | 29 +++++ .../examples/calculator/RunCucumberTest.kt | 19 +++ .../calculator/ShoppingStepDefinitions.kt | 56 +++++++++ .../calculator/basic_arithmetic.feature | 35 ++++++ .../calculator/date_calculator.feature | 8 ++ .../examples/calculator/shopping.feature | 11 ++ examples/pom.xml | 118 +++++++++--------- 8 files changed, 301 insertions(+), 61 deletions(-) create mode 100644 examples/calculator-kotlin-testng/pom.xml create mode 100644 examples/calculator-kotlin-testng/src/main/kotlin/io/cucumber/examples/calaculator/RpnCalculator.kt create mode 100644 examples/calculator-kotlin-testng/src/test/kotlin/io/cucumber/examples/calculator/RunCucumberTest.kt create mode 100644 examples/calculator-kotlin-testng/src/test/kotlin/io/cucumber/examples/calculator/ShoppingStepDefinitions.kt create mode 100644 examples/calculator-kotlin-testng/src/test/resources/io/cucumber/examples/calculator/basic_arithmetic.feature create mode 100644 examples/calculator-kotlin-testng/src/test/resources/io/cucumber/examples/calculator/date_calculator.feature create mode 100644 examples/calculator-kotlin-testng/src/test/resources/io/cucumber/examples/calculator/shopping.feature diff --git a/examples/calculator-kotlin-testng/pom.xml b/examples/calculator-kotlin-testng/pom.xml new file mode 100644 index 0000000000..84313d0101 --- /dev/null +++ b/examples/calculator-kotlin-testng/pom.xml @@ -0,0 +1,86 @@ + + + + 4.0.0 + + + examples + io.cucumber + 7.22.3-SNAPSHOT + + + calculator-kotlin-testng + 1.0-SNAPSHOT + jar + + Kotlin Examples: Calculator - Annotations - TestNG + + + UTF-8 + 1.9.0 + official + 4.13.1 + + + + + org.jetbrains.kotlin + kotlin-stdlib + ${kotlin.version} + + + org.jetbrains.kotlin + kotlin-test-junit + ${kotlin.version} + test + + + junit + junit + ${junit.version} + test + + + io.cucumber + cucumber-java + 7.22.3-SNAPSHOT + test + + + io.cucumber + cucumber-testng + 7.22.3-SNAPSHOT + test + + + + + src/main/kotlin + src/test/kotlin + + + + org.jetbrains.kotlin + kotlin-maven-plugin + ${kotlin.version} + + + compile + compile + + compile + + + + test-compile + test-compile + + test-compile + + + + + + + + diff --git a/examples/calculator-kotlin-testng/src/main/kotlin/io/cucumber/examples/calaculator/RpnCalculator.kt b/examples/calculator-kotlin-testng/src/main/kotlin/io/cucumber/examples/calaculator/RpnCalculator.kt new file mode 100644 index 0000000000..d6433bbde2 --- /dev/null +++ b/examples/calculator-kotlin-testng/src/main/kotlin/io/cucumber/examples/calaculator/RpnCalculator.kt @@ -0,0 +1,29 @@ +package io.cucumber.examples.calaculator + +class RpnCalculator { + private val stack: ArrayDeque = ArrayDeque() + + private val OPS = setOf("+", "-", "*", "/") + + fun push(arg: Any) { + if (arg in OPS) { + val y = stack.removeLast() + val x = if (stack.isEmpty()) 0 else stack.removeLast() + val valResult = when (arg) { + "-" -> x.toDouble() - y.toDouble() + "+" -> x.toDouble() + y.toDouble() + "*" -> x.toDouble() * y.toDouble() + "/" -> x.toDouble() / y.toDouble() + else -> throw IllegalArgumentException("Unknown operation $arg") + } + push(valResult) + } else { + stack.addLast(arg as Number) + } + } + + fun peek(): Number? = stack.lastOrNull() + + fun clear() = stack.clear() +} + diff --git a/examples/calculator-kotlin-testng/src/test/kotlin/io/cucumber/examples/calculator/RunCucumberTest.kt b/examples/calculator-kotlin-testng/src/test/kotlin/io/cucumber/examples/calculator/RunCucumberTest.kt new file mode 100644 index 0000000000..b2e2485456 --- /dev/null +++ b/examples/calculator-kotlin-testng/src/test/kotlin/io/cucumber/examples/calculator/RunCucumberTest.kt @@ -0,0 +1,19 @@ +package io.cucumber.examples.calculator + +import io.cucumber.testng.AbstractTestNGCucumberTests +import io.cucumber.testng.CucumberOptions +import org.testng.annotations.DataProvider + + +@CucumberOptions( + plugin = ["html:target/results.html"], +// tags = "@shopping" +) +class RunCucumberTest : AbstractTestNGCucumberTests() { + + @DataProvider + override fun scenarios(): Array> { + return super.scenarios() + } + +} diff --git a/examples/calculator-kotlin-testng/src/test/kotlin/io/cucumber/examples/calculator/ShoppingStepDefinitions.kt b/examples/calculator-kotlin-testng/src/test/kotlin/io/cucumber/examples/calculator/ShoppingStepDefinitions.kt new file mode 100644 index 0000000000..adc5060d1b --- /dev/null +++ b/examples/calculator-kotlin-testng/src/test/kotlin/io/cucumber/examples/calculator/ShoppingStepDefinitions.kt @@ -0,0 +1,56 @@ +package io.cucumber.examples.calculator + +import io.cucumber.datatable.DataTable +import io.cucumber.examples.calaculator.RpnCalculator +import io.cucumber.java.DataTableType +import io.cucumber.java.en.Given +import io.cucumber.java.en.Then +import io.cucumber.java.en.When +import kotlin.test.assertEquals + +class ShoppingStepDefinitions { + private val rpnCalculator = RpnCalculator() + private val groceryList = mutableListOf() + + + + @Given("the following groceries") + fun givenTheFollowingGroceries(grocery: DataTable){ + val groceries: List = grocery.asList(Grocery::class.java) + groceryList.addAll(groceries) + for (gro in groceries){ + rpnCalculator.push(gro.price.value) + rpnCalculator.push("+") + } + } + + @When("I pay {int}") + fun whenIPay(amount: Int) { + rpnCalculator.push(amount) + rpnCalculator.push("-") + } + + @Then("my change should be {int}") + fun myChangeShouldBe(change: Int) { + rpnCalculator.peek()?.let { assertEquals(change, -it.toInt()) } + } + + @DataTableType + fun groceryEntry(entry: Map): Grocery { + val name = entry["name"] ?: error("Missing name") + val price = Price.fromString(entry["price"] ?: error("Missing price")) + return Grocery(name, price) + } + + data class Grocery(val name: String, val price: Price) + + @JvmInline + value class Price(val value: Int) { + companion object { + fun fromString(value: String): Price { + return Price(value.toInt()) + } + } + } + +} diff --git a/examples/calculator-kotlin-testng/src/test/resources/io/cucumber/examples/calculator/basic_arithmetic.feature b/examples/calculator-kotlin-testng/src/test/resources/io/cucumber/examples/calculator/basic_arithmetic.feature new file mode 100644 index 0000000000..79b252a23d --- /dev/null +++ b/examples/calculator-kotlin-testng/src/test/resources/io/cucumber/examples/calculator/basic_arithmetic.feature @@ -0,0 +1,35 @@ +@foo +Feature: Basic Arithmetic + + Background: A Calculator + Given a calculator I just turned on + + Scenario: Addition + # Try to change one of the values below to provoke a failure + When I add 4 and 5 + Then the result is 9 + + Scenario: Another Addition + # Try to change one of the values below to provoke a failure + When I add 4 and 7 + Then the result is 11 + + Scenario Outline: Many additions + Given the previous entries: + | first | second | operation | + | 1 | 1 | + | + | 2 | 1 | + | + When I press + + And I add and + And I press + + Then the result is + + Examples: Single digits + | a | b | c | + | 1 | 2 | 8 | + | 2 | 3 | 10 | + + Examples: Double digits + | a | b | c | + | 10 | 20 | 35 | + | 20 | 30 | 55 | diff --git a/examples/calculator-kotlin-testng/src/test/resources/io/cucumber/examples/calculator/date_calculator.feature b/examples/calculator-kotlin-testng/src/test/resources/io/cucumber/examples/calculator/date_calculator.feature new file mode 100644 index 0000000000..b5295ccbd1 --- /dev/null +++ b/examples/calculator-kotlin-testng/src/test/resources/io/cucumber/examples/calculator/date_calculator.feature @@ -0,0 +1,8 @@ +Feature: Dates with different date formats + This feature shows you can have different date formats, as long as you annotate the + corresponding step definition method accordingly. + + Scenario: Determine past date + Given today is 2011-01-20 + When I ask if Jan 19, 2011 is in the past + Then the result should be yes diff --git a/examples/calculator-kotlin-testng/src/test/resources/io/cucumber/examples/calculator/shopping.feature b/examples/calculator-kotlin-testng/src/test/resources/io/cucumber/examples/calculator/shopping.feature new file mode 100644 index 0000000000..87089ce083 --- /dev/null +++ b/examples/calculator-kotlin-testng/src/test/resources/io/cucumber/examples/calculator/shopping.feature @@ -0,0 +1,11 @@ +Feature: Shopping + + @shopping + Scenario: Give correct change + Given the following groceries + | name | price | + | milk | 9 | + | bread | 7 | + | soap | 5 | + When I pay 25 + Then my change should be 4 diff --git a/examples/pom.xml b/examples/pom.xml index dc705ed806..dc3d423f80 100644 --- a/examples/pom.xml +++ b/examples/pom.xml @@ -1,62 +1,58 @@ - - 4.0.0 - - - io.cucumber - cucumber-jvm - 7.22.3-SNAPSHOT - - - examples - pom - Examples - - - calculator-java8-cli - calculator-java-cli - calculator-java-junit4 - calculator-java-junit5 - calculator-java-testng - spring-java-junit5 - wicket-java-junit4 - - - - - - - maven-jar-plugin - - true - - - - maven-install-plugin - - true - - - - maven-javadoc-plugin - - true - - - - maven-deploy-plugin - - true - - - - org.revapi - revapi-maven-plugin - - true - - - - - + + 4.0.0 + + io.cucumber + cucumber-jvm + 7.22.3-SNAPSHOT + + examples + pom + Examples + + calculator-java8-cli + calculator-java-cli + calculator-java-junit4 + calculator-java-junit5 + calculator-java-testng + spring-java-junit5 + wicket-java-junit4 + calculator-kotlin-testng + + + + + + maven-jar-plugin + + true + + + + maven-install-plugin + + true + + + + maven-javadoc-plugin + + true + + + + maven-deploy-plugin + + true + + + + org.revapi + revapi-maven-plugin + + true + + + + + - From b0db4b4078343d2959bf097eee5cb2c43fb98362 Mon Sep 17 00:00:00 2001 From: Jitendra_Singh2 Date: Sat, 17 May 2025 04:11:01 +0530 Subject: [PATCH 13/24] add examples for Kotlin date_calculator.feature Signed-off-by: Jitendra_Singh2 --- .../io/cucumber/examples/calculator/date_calculator.feature | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/calculator-kotlin-testng/src/test/resources/io/cucumber/examples/calculator/date_calculator.feature b/examples/calculator-kotlin-testng/src/test/resources/io/cucumber/examples/calculator/date_calculator.feature index b5295ccbd1..ed665e833d 100644 --- a/examples/calculator-kotlin-testng/src/test/resources/io/cucumber/examples/calculator/date_calculator.feature +++ b/examples/calculator-kotlin-testng/src/test/resources/io/cucumber/examples/calculator/date_calculator.feature @@ -2,7 +2,8 @@ Feature: Dates with different date formats This feature shows you can have different date formats, as long as you annotate the corresponding step definition method accordingly. + @date Scenario: Determine past date Given today is 2011-01-20 When I ask if Jan 19, 2011 is in the past - Then the result should be yes + Then the result should be "yes" From 7f46e5f0e77f7528c43de732c50dd86ebafac9a9 Mon Sep 17 00:00:00 2001 From: Jitendra_Singh2 Date: Sat, 17 May 2025 04:25:02 +0530 Subject: [PATCH 14/24] add implementations for Kotlin date_calculator.feature Signed-off-by: Jitendra_Singh2 --- .../examples/calaculator/DateCalculator.kt | 12 +++++++ .../calculator/DateStepDefinitions.kt | 36 +++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 examples/calculator-kotlin-testng/src/main/kotlin/io/cucumber/examples/calaculator/DateCalculator.kt create mode 100644 examples/calculator-kotlin-testng/src/test/kotlin/io/cucumber/examples/calculator/DateStepDefinitions.kt diff --git a/examples/calculator-kotlin-testng/src/main/kotlin/io/cucumber/examples/calaculator/DateCalculator.kt b/examples/calculator-kotlin-testng/src/main/kotlin/io/cucumber/examples/calaculator/DateCalculator.kt new file mode 100644 index 0000000000..5f3ec14be0 --- /dev/null +++ b/examples/calculator-kotlin-testng/src/main/kotlin/io/cucumber/examples/calaculator/DateCalculator.kt @@ -0,0 +1,12 @@ +package io.cucumber.examples.calaculator + +import java.time.LocalDate +import java.util.* + +class DateCalculator(private val now: LocalDate) { + + fun isDateInThePast(date: LocalDate): String { + return if (date.isBefore(now)) "yes" else "no" + } +} + diff --git a/examples/calculator-kotlin-testng/src/test/kotlin/io/cucumber/examples/calculator/DateStepDefinitions.kt b/examples/calculator-kotlin-testng/src/test/kotlin/io/cucumber/examples/calculator/DateStepDefinitions.kt new file mode 100644 index 0000000000..df99b40f09 --- /dev/null +++ b/examples/calculator-kotlin-testng/src/test/kotlin/io/cucumber/examples/calculator/DateStepDefinitions.kt @@ -0,0 +1,36 @@ +package io.cucumber.examples.calculator + +import io.cucumber.examples.calaculator.DateCalculator +import io.cucumber.java.en.Given +import io.cucumber.java.en.Then +import io.cucumber.java.en.When +import java.time.LocalDate +import java.time.format.DateTimeFormatter +import java.util.* +import kotlin.test.assertEquals + +class DateStepDefinitions { + + private lateinit var result: String + + private lateinit var calculator: DateCalculator + + + @Given("today is {}") + fun todayIs(date: String) { + val date1 = LocalDate.parse(date) + calculator = DateCalculator(now = date1) + } + + @When("I ask if {} is in the past") + fun iAskIfDateIsInPast(date: String) { + val formatter: DateTimeFormatter = DateTimeFormatter.ofPattern("MMM d, yyyy", Locale.ENGLISH) + val date2 = LocalDate.parse(date,formatter) + result = calculator.isDateInThePast(date2) + } + + @Then("the result should be {string}") + fun theResultShouldBeYes(answer: String) { + assertEquals(answer, result) + } +} From b954cfc74c7a0e6e1cb03a45a76e4f9296d2e08e Mon Sep 17 00:00:00 2001 From: Jitendra_Singh2 Date: Sat, 17 May 2025 04:26:05 +0530 Subject: [PATCH 15/24] remove tag from RunCucumberTest.kt Signed-off-by: Jitendra_Singh2 --- .../kotlin/io/cucumber/examples/calculator/RunCucumberTest.kt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/examples/calculator-kotlin-testng/src/test/kotlin/io/cucumber/examples/calculator/RunCucumberTest.kt b/examples/calculator-kotlin-testng/src/test/kotlin/io/cucumber/examples/calculator/RunCucumberTest.kt index b2e2485456..88c8c7bfef 100644 --- a/examples/calculator-kotlin-testng/src/test/kotlin/io/cucumber/examples/calculator/RunCucumberTest.kt +++ b/examples/calculator-kotlin-testng/src/test/kotlin/io/cucumber/examples/calculator/RunCucumberTest.kt @@ -6,8 +6,7 @@ import org.testng.annotations.DataProvider @CucumberOptions( - plugin = ["html:target/results.html"], -// tags = "@shopping" + plugin = ["html:target/results.html"] ) class RunCucumberTest : AbstractTestNGCucumberTests() { From e6fba3791027717cf3e24bf75115434428147a03 Mon Sep 17 00:00:00 2001 From: Jitendra Singh2 <138148209+jit3pam@users.noreply.github.com> Date: Mon, 19 May 2025 16:17:44 +0530 Subject: [PATCH 16/24] Update examples/calculator-kotlin-testng/pom.xml Co-authored-by: M.P. Korstanje --- examples/calculator-kotlin-testng/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/calculator-kotlin-testng/pom.xml b/examples/calculator-kotlin-testng/pom.xml index 84313d0101..1df7604c40 100644 --- a/examples/calculator-kotlin-testng/pom.xml +++ b/examples/calculator-kotlin-testng/pom.xml @@ -13,7 +13,7 @@ 1.0-SNAPSHOT jar - Kotlin Examples: Calculator - Annotations - TestNG + Examples: Calculator - Kotlin - Annotations - TestNG UTF-8 From 8125d057da1a452ed7e8230dbd7780f7b63154a0 Mon Sep 17 00:00:00 2001 From: Jitendra_Singh2 Date: Tue, 20 May 2025 03:22:52 +0530 Subject: [PATCH 17/24] restore pom.xml in examples Signed-off-by: Jitendra_Singh2 --- examples/pom.xml | 118 ++++++++++++++++++++++++----------------------- 1 file changed, 61 insertions(+), 57 deletions(-) diff --git a/examples/pom.xml b/examples/pom.xml index dc3d423f80..1185568465 100644 --- a/examples/pom.xml +++ b/examples/pom.xml @@ -1,58 +1,62 @@ - - 4.0.0 - - io.cucumber - cucumber-jvm - 7.22.3-SNAPSHOT - - examples - pom - Examples - - calculator-java8-cli - calculator-java-cli - calculator-java-junit4 - calculator-java-junit5 - calculator-java-testng - spring-java-junit5 - wicket-java-junit4 - calculator-kotlin-testng - - - - - - maven-jar-plugin - - true - - - - maven-install-plugin - - true - - - - maven-javadoc-plugin - - true - - - - maven-deploy-plugin - - true - - - - org.revapi - revapi-maven-plugin - - true - - - - - + + 4.0.0 + + + io.cucumber + cucumber-jvm + 7.22.3-SNAPSHOT + + + examples + pom + Examples + + + calculator-java8-cli + calculator-java-cli + calculator-java-junit4 + calculator-java-junit5 + calculator-java-testng + spring-java-junit5 + wicket-java-junit4 + + + + + + + maven-jar-plugin + + true + + + + maven-install-plugin + + true + + + + maven-javadoc-plugin + + true + + + + maven-deploy-plugin + + true + + + + org.revapi + revapi-maven-plugin + + true + + + + + + From 8c1d5cffd6dd730fceff78a682be5997f62fabcf Mon Sep 17 00:00:00 2001 From: Jitendra_Singh2 Date: Wed, 21 May 2025 10:06:36 +0530 Subject: [PATCH 18/24] update examples to use junit5 Signed-off-by: Jitendra_Singh2 --- .../.gitignore | 0 examples/calculator-kotlin-junit5/pom.xml | 180 ++++++++++++++++++ .../examples/calaculator/DateCalculator.kt | 0 .../examples/calaculator/RpnCalculator.kt | 0 .../calculator/DateStepDefinitions.kt | 0 .../calculator/RunCucumberKotlinTest.kt | 12 ++ .../calculator/ShoppingStepDefinitions.kt | 0 .../calculator/date_calculator.feature | 0 .../examples/calculator/shopping.feature | 0 examples/calculator-kotlin-testng/pom.xml | 86 --------- .../examples/calculator/RunCucumberTest.kt | 18 -- .../calculator/basic_arithmetic.feature | 35 ---- examples/pom.xml | 1 + 13 files changed, 193 insertions(+), 139 deletions(-) rename examples/{calculator-kotlin-testng => calculator-kotlin-junit5}/.gitignore (100%) create mode 100644 examples/calculator-kotlin-junit5/pom.xml rename examples/{calculator-kotlin-testng => calculator-kotlin-junit5}/src/main/kotlin/io/cucumber/examples/calaculator/DateCalculator.kt (100%) rename examples/{calculator-kotlin-testng => calculator-kotlin-junit5}/src/main/kotlin/io/cucumber/examples/calaculator/RpnCalculator.kt (100%) rename examples/{calculator-kotlin-testng => calculator-kotlin-junit5}/src/test/kotlin/io/cucumber/examples/calculator/DateStepDefinitions.kt (100%) create mode 100644 examples/calculator-kotlin-junit5/src/test/kotlin/io/cucumber/examples/calculator/RunCucumberKotlinTest.kt rename examples/{calculator-kotlin-testng => calculator-kotlin-junit5}/src/test/kotlin/io/cucumber/examples/calculator/ShoppingStepDefinitions.kt (100%) rename examples/{calculator-kotlin-testng => calculator-kotlin-junit5}/src/test/resources/io/cucumber/examples/calculator/date_calculator.feature (100%) rename examples/{calculator-kotlin-testng => calculator-kotlin-junit5}/src/test/resources/io/cucumber/examples/calculator/shopping.feature (100%) delete mode 100644 examples/calculator-kotlin-testng/pom.xml delete mode 100644 examples/calculator-kotlin-testng/src/test/kotlin/io/cucumber/examples/calculator/RunCucumberTest.kt delete mode 100644 examples/calculator-kotlin-testng/src/test/resources/io/cucumber/examples/calculator/basic_arithmetic.feature diff --git a/examples/calculator-kotlin-testng/.gitignore b/examples/calculator-kotlin-junit5/.gitignore similarity index 100% rename from examples/calculator-kotlin-testng/.gitignore rename to examples/calculator-kotlin-junit5/.gitignore diff --git a/examples/calculator-kotlin-junit5/pom.xml b/examples/calculator-kotlin-junit5/pom.xml new file mode 100644 index 0000000000..d60a404426 --- /dev/null +++ b/examples/calculator-kotlin-junit5/pom.xml @@ -0,0 +1,180 @@ + + + + 4.0.0 + + + examples + io.cucumber + 7.22.3-SNAPSHOT + + + calculator-kotlin-junit5 + jar + + Examples: Calculator - Kotlin - Annotations - TestNG + + + UTF-8 + 1.9.0 + official + 5.12.2 + io.cucumber.examples.calculator + + + + + + io.cucumber + cucumber-bom + ${project.version} + pom + import + + + org.junit + junit-bom + ${junit-jupiter.version} + pom + import + + + + + + + org.jetbrains.kotlin + kotlin-stdlib + ${kotlin.version} + + + org.jetbrains.kotlin + kotlin-test-junit + ${kotlin.version} + test + + + io.cucumber + cucumber-junit-platform-engine + test + + + org.junit.platform + junit-platform-suite + 1.12.2 + test + + + org.junit.jupiter + junit-jupiter + 5.12.2 + test + + + org.junit.jupiter + junit-jupiter-api + ${junit-jupiter.version} + test + + + org.junit.jupiter + junit-jupiter-engine + ${junit-jupiter.version} + test + + + org.junit.platform + junit-platform-console + test + + + io.cucumber + cucumber-java + 7.22.3-SNAPSHOT + test + + + io.cucumber + cucumber-testng + 7.22.3-SNAPSHOT + test + + + + + src/main/kotlin + src/test/kotlin + + + + org.jetbrains.kotlin + kotlin-maven-plugin + ${kotlin.version} + + + compile + compile + + compile + + + + test-compile + test-compile + + test-compile + + + + + + maven-failsafe-plugin + 3.5.3 + + + org.apache.maven.plugins + maven-surefire-plugin + + + + + cucumber.junit-platform.naming-strategy=long + + + + + + org.apache.maven.plugins + maven-antrun-plugin + + + + cli-test + test + + run + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/calculator-kotlin-testng/src/main/kotlin/io/cucumber/examples/calaculator/DateCalculator.kt b/examples/calculator-kotlin-junit5/src/main/kotlin/io/cucumber/examples/calaculator/DateCalculator.kt similarity index 100% rename from examples/calculator-kotlin-testng/src/main/kotlin/io/cucumber/examples/calaculator/DateCalculator.kt rename to examples/calculator-kotlin-junit5/src/main/kotlin/io/cucumber/examples/calaculator/DateCalculator.kt diff --git a/examples/calculator-kotlin-testng/src/main/kotlin/io/cucumber/examples/calaculator/RpnCalculator.kt b/examples/calculator-kotlin-junit5/src/main/kotlin/io/cucumber/examples/calaculator/RpnCalculator.kt similarity index 100% rename from examples/calculator-kotlin-testng/src/main/kotlin/io/cucumber/examples/calaculator/RpnCalculator.kt rename to examples/calculator-kotlin-junit5/src/main/kotlin/io/cucumber/examples/calaculator/RpnCalculator.kt diff --git a/examples/calculator-kotlin-testng/src/test/kotlin/io/cucumber/examples/calculator/DateStepDefinitions.kt b/examples/calculator-kotlin-junit5/src/test/kotlin/io/cucumber/examples/calculator/DateStepDefinitions.kt similarity index 100% rename from examples/calculator-kotlin-testng/src/test/kotlin/io/cucumber/examples/calculator/DateStepDefinitions.kt rename to examples/calculator-kotlin-junit5/src/test/kotlin/io/cucumber/examples/calculator/DateStepDefinitions.kt diff --git a/examples/calculator-kotlin-junit5/src/test/kotlin/io/cucumber/examples/calculator/RunCucumberKotlinTest.kt b/examples/calculator-kotlin-junit5/src/test/kotlin/io/cucumber/examples/calculator/RunCucumberKotlinTest.kt new file mode 100644 index 0000000000..5bc6ff3185 --- /dev/null +++ b/examples/calculator-kotlin-junit5/src/test/kotlin/io/cucumber/examples/calculator/RunCucumberKotlinTest.kt @@ -0,0 +1,12 @@ +package io.cucumber.examples.calculator + +import io.cucumber.junit.platform.engine.Constants +import org.junit.platform.suite.api.* + + +@Suite +@IncludeEngines("cucumber") +@SelectPackages("io.cucumber.examples.calculator") +@ConfigurationParameter(key = Constants.GLUE_PROPERTY_NAME, value = "io.cucumber.examples.calculator") +@SelectClasspathResource("io.cucumber.examples.calculator") +class RunCucumberKotlinTest diff --git a/examples/calculator-kotlin-testng/src/test/kotlin/io/cucumber/examples/calculator/ShoppingStepDefinitions.kt b/examples/calculator-kotlin-junit5/src/test/kotlin/io/cucumber/examples/calculator/ShoppingStepDefinitions.kt similarity index 100% rename from examples/calculator-kotlin-testng/src/test/kotlin/io/cucumber/examples/calculator/ShoppingStepDefinitions.kt rename to examples/calculator-kotlin-junit5/src/test/kotlin/io/cucumber/examples/calculator/ShoppingStepDefinitions.kt diff --git a/examples/calculator-kotlin-testng/src/test/resources/io/cucumber/examples/calculator/date_calculator.feature b/examples/calculator-kotlin-junit5/src/test/resources/io/cucumber/examples/calculator/date_calculator.feature similarity index 100% rename from examples/calculator-kotlin-testng/src/test/resources/io/cucumber/examples/calculator/date_calculator.feature rename to examples/calculator-kotlin-junit5/src/test/resources/io/cucumber/examples/calculator/date_calculator.feature diff --git a/examples/calculator-kotlin-testng/src/test/resources/io/cucumber/examples/calculator/shopping.feature b/examples/calculator-kotlin-junit5/src/test/resources/io/cucumber/examples/calculator/shopping.feature similarity index 100% rename from examples/calculator-kotlin-testng/src/test/resources/io/cucumber/examples/calculator/shopping.feature rename to examples/calculator-kotlin-junit5/src/test/resources/io/cucumber/examples/calculator/shopping.feature diff --git a/examples/calculator-kotlin-testng/pom.xml b/examples/calculator-kotlin-testng/pom.xml deleted file mode 100644 index 1df7604c40..0000000000 --- a/examples/calculator-kotlin-testng/pom.xml +++ /dev/null @@ -1,86 +0,0 @@ - - - - 4.0.0 - - - examples - io.cucumber - 7.22.3-SNAPSHOT - - - calculator-kotlin-testng - 1.0-SNAPSHOT - jar - - Examples: Calculator - Kotlin - Annotations - TestNG - - - UTF-8 - 1.9.0 - official - 4.13.1 - - - - - org.jetbrains.kotlin - kotlin-stdlib - ${kotlin.version} - - - org.jetbrains.kotlin - kotlin-test-junit - ${kotlin.version} - test - - - junit - junit - ${junit.version} - test - - - io.cucumber - cucumber-java - 7.22.3-SNAPSHOT - test - - - io.cucumber - cucumber-testng - 7.22.3-SNAPSHOT - test - - - - - src/main/kotlin - src/test/kotlin - - - - org.jetbrains.kotlin - kotlin-maven-plugin - ${kotlin.version} - - - compile - compile - - compile - - - - test-compile - test-compile - - test-compile - - - - - - - - diff --git a/examples/calculator-kotlin-testng/src/test/kotlin/io/cucumber/examples/calculator/RunCucumberTest.kt b/examples/calculator-kotlin-testng/src/test/kotlin/io/cucumber/examples/calculator/RunCucumberTest.kt deleted file mode 100644 index 88c8c7bfef..0000000000 --- a/examples/calculator-kotlin-testng/src/test/kotlin/io/cucumber/examples/calculator/RunCucumberTest.kt +++ /dev/null @@ -1,18 +0,0 @@ -package io.cucumber.examples.calculator - -import io.cucumber.testng.AbstractTestNGCucumberTests -import io.cucumber.testng.CucumberOptions -import org.testng.annotations.DataProvider - - -@CucumberOptions( - plugin = ["html:target/results.html"] -) -class RunCucumberTest : AbstractTestNGCucumberTests() { - - @DataProvider - override fun scenarios(): Array> { - return super.scenarios() - } - -} diff --git a/examples/calculator-kotlin-testng/src/test/resources/io/cucumber/examples/calculator/basic_arithmetic.feature b/examples/calculator-kotlin-testng/src/test/resources/io/cucumber/examples/calculator/basic_arithmetic.feature deleted file mode 100644 index 79b252a23d..0000000000 --- a/examples/calculator-kotlin-testng/src/test/resources/io/cucumber/examples/calculator/basic_arithmetic.feature +++ /dev/null @@ -1,35 +0,0 @@ -@foo -Feature: Basic Arithmetic - - Background: A Calculator - Given a calculator I just turned on - - Scenario: Addition - # Try to change one of the values below to provoke a failure - When I add 4 and 5 - Then the result is 9 - - Scenario: Another Addition - # Try to change one of the values below to provoke a failure - When I add 4 and 7 - Then the result is 11 - - Scenario Outline: Many additions - Given the previous entries: - | first | second | operation | - | 1 | 1 | + | - | 2 | 1 | + | - When I press + - And I add and - And I press + - Then the result is - - Examples: Single digits - | a | b | c | - | 1 | 2 | 8 | - | 2 | 3 | 10 | - - Examples: Double digits - | a | b | c | - | 10 | 20 | 35 | - | 20 | 30 | 55 | diff --git a/examples/pom.xml b/examples/pom.xml index 1185568465..6b75b50096 100644 --- a/examples/pom.xml +++ b/examples/pom.xml @@ -19,6 +19,7 @@ calculator-java-testng spring-java-junit5 wicket-java-junit4 + calculator-kotlin-junit5 From 450409cf74d28509011f1b939d3731214b1dbed6 Mon Sep 17 00:00:00 2001 From: Jitendra_Singh2 Date: Wed, 21 May 2025 11:57:04 +0530 Subject: [PATCH 19/24] update dependencies in pom.xml Signed-off-by: Jitendra_Singh2 --- examples/calculator-kotlin-junit5/pom.xml | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/examples/calculator-kotlin-junit5/pom.xml b/examples/calculator-kotlin-junit5/pom.xml index d60a404426..161309a667 100644 --- a/examples/calculator-kotlin-junit5/pom.xml +++ b/examples/calculator-kotlin-junit5/pom.xml @@ -12,7 +12,7 @@ calculator-kotlin-junit5 jar - Examples: Calculator - Kotlin - Annotations - TestNG + Examples: Calculator - Kotlin - Annotations - Junit 5 UTF-8 @@ -67,7 +67,7 @@ org.junit.jupiter junit-jupiter - 5.12.2 + ${junit-jupiter.version} test @@ -90,15 +90,9 @@ io.cucumber cucumber-java - 7.22.3-SNAPSHOT - test - - - io.cucumber - cucumber-testng - 7.22.3-SNAPSHOT test + From 8390b15fdcd057e29b7bc02edbec8a6643d04edb Mon Sep 17 00:00:00 2001 From: Jitendra_Singh2 Date: Wed, 21 May 2025 13:36:54 +0530 Subject: [PATCH 20/24] update dependencies in pom.xml, and change .* imports to explicit imports Signed-off-by: Jitendra_Singh2 --- examples/calculator-kotlin-junit5/pom.xml | 10 +++++----- .../examples/calculator/DateStepDefinitions.kt | 2 +- .../examples/calculator/RunCucumberKotlinTest.kt | 6 +++++- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/examples/calculator-kotlin-junit5/pom.xml b/examples/calculator-kotlin-junit5/pom.xml index 161309a667..b01394af3f 100644 --- a/examples/calculator-kotlin-junit5/pom.xml +++ b/examples/calculator-kotlin-junit5/pom.xml @@ -42,6 +42,11 @@ + + io.cucumber + cucumber-java + test + org.jetbrains.kotlin kotlin-stdlib @@ -87,11 +92,6 @@ junit-platform-console test - - io.cucumber - cucumber-java - test - diff --git a/examples/calculator-kotlin-junit5/src/test/kotlin/io/cucumber/examples/calculator/DateStepDefinitions.kt b/examples/calculator-kotlin-junit5/src/test/kotlin/io/cucumber/examples/calculator/DateStepDefinitions.kt index df99b40f09..538521121b 100644 --- a/examples/calculator-kotlin-junit5/src/test/kotlin/io/cucumber/examples/calculator/DateStepDefinitions.kt +++ b/examples/calculator-kotlin-junit5/src/test/kotlin/io/cucumber/examples/calculator/DateStepDefinitions.kt @@ -6,7 +6,7 @@ import io.cucumber.java.en.Then import io.cucumber.java.en.When import java.time.LocalDate import java.time.format.DateTimeFormatter -import java.util.* +import java.util.Locale import kotlin.test.assertEquals class DateStepDefinitions { diff --git a/examples/calculator-kotlin-junit5/src/test/kotlin/io/cucumber/examples/calculator/RunCucumberKotlinTest.kt b/examples/calculator-kotlin-junit5/src/test/kotlin/io/cucumber/examples/calculator/RunCucumberKotlinTest.kt index 5bc6ff3185..b82457b0e0 100644 --- a/examples/calculator-kotlin-junit5/src/test/kotlin/io/cucumber/examples/calculator/RunCucumberKotlinTest.kt +++ b/examples/calculator-kotlin-junit5/src/test/kotlin/io/cucumber/examples/calculator/RunCucumberKotlinTest.kt @@ -1,7 +1,11 @@ package io.cucumber.examples.calculator import io.cucumber.junit.platform.engine.Constants -import org.junit.platform.suite.api.* +import org.junit.platform.suite.api.Suite +import org.junit.platform.suite.api.IncludeEngines +import org.junit.platform.suite.api.SelectPackages +import org.junit.platform.suite.api.ConfigurationParameter +import org.junit.platform.suite.api.SelectClasspathResource @Suite From 0a28103149884019f7fbacc6c38b5697b1781fb1 Mon Sep 17 00:00:00 2001 From: Jitendra_Singh2 Date: Wed, 21 May 2025 22:16:33 +0530 Subject: [PATCH 21/24] restore the xml in examples Signed-off-by: Jitendra_Singh2 --- examples/pom.xml | 63 ------------------------------------------------ 1 file changed, 63 deletions(-) delete mode 100644 examples/pom.xml diff --git a/examples/pom.xml b/examples/pom.xml deleted file mode 100644 index 6b75b50096..0000000000 --- a/examples/pom.xml +++ /dev/null @@ -1,63 +0,0 @@ - - 4.0.0 - - - io.cucumber - cucumber-jvm - 7.22.3-SNAPSHOT - - - examples - pom - Examples - - - calculator-java8-cli - calculator-java-cli - calculator-java-junit4 - calculator-java-junit5 - calculator-java-testng - spring-java-junit5 - wicket-java-junit4 - calculator-kotlin-junit5 - - - - - - - maven-jar-plugin - - true - - - - maven-install-plugin - - true - - - - maven-javadoc-plugin - - true - - - - maven-deploy-plugin - - true - - - - org.revapi - revapi-maven-plugin - - true - - - - - - - From 34785320db053516c65e9b3749d74f03e810a712 Mon Sep 17 00:00:00 2001 From: Jitendra_Singh2 Date: Wed, 21 May 2025 22:42:38 +0530 Subject: [PATCH 22/24] update the tags in examples/pom.xml --- examples/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/pom.xml b/examples/pom.xml index 6b75b50096..817700a36e 100644 --- a/examples/pom.xml +++ b/examples/pom.xml @@ -1,4 +1,4 @@ - + 4.0.0 From 1f83c0b30e49ef8fa9df7c802e457f0a810701f9 Mon Sep 17 00:00:00 2001 From: "M.P. Korstanje" Date: Fri, 23 May 2025 17:22:12 +0200 Subject: [PATCH 23/24] [All] Set version to 7.23.0-SNAPSHOT --- examples/calculator-kotlin-junit5/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/calculator-kotlin-junit5/pom.xml b/examples/calculator-kotlin-junit5/pom.xml index b01394af3f..3844011a8b 100644 --- a/examples/calculator-kotlin-junit5/pom.xml +++ b/examples/calculator-kotlin-junit5/pom.xml @@ -6,7 +6,7 @@ examples io.cucumber - 7.22.3-SNAPSHOT + 7.23.0-SNAPSHOT calculator-kotlin-junit5 From b253d5e23678f629c5e979e9dfece4363daa8b29 Mon Sep 17 00:00:00 2001 From: "M.P. Korstanje" Date: Fri, 23 May 2025 17:47:28 +0200 Subject: [PATCH 24/24] Harmonize --- examples/calculator-java-cli/pom.xml | 2 +- examples/calculator-java-junit4/pom.xml | 2 +- examples/calculator-java-junit5/pom.xml | 44 ++++++----- .../calculator/DateStepDefinitions.java | 4 +- .../calculator/RpnCalculatorSteps.java | 4 +- .../examples/calculator/ShoppingSteps.java | 4 +- examples/calculator-java-testng/pom.xml | 2 +- examples/calculator-java8-cli/pom.xml | 2 +- examples/calculator-kotlin-junit5/pom.xml | 74 ++++++++----------- .../calculator/RunCucumberKotlinTest.kt | 12 +-- examples/pom.xml | 2 +- examples/spring-java-junit5/pom.xml | 2 +- 12 files changed, 75 insertions(+), 79 deletions(-) diff --git a/examples/calculator-java-cli/pom.xml b/examples/calculator-java-cli/pom.xml index 1f026bb29c..493a6f4890 100644 --- a/examples/calculator-java-cli/pom.xml +++ b/examples/calculator-java-cli/pom.xml @@ -9,7 +9,7 @@ calculator-java-cli jar - Examples: Calculator - Annotations - CLI + Examples: Calculator - Java - Annotations - CLI io.cucumber.examples.calculator diff --git a/examples/calculator-java-junit4/pom.xml b/examples/calculator-java-junit4/pom.xml index 98c4e651fc..ae7cb1a49a 100644 --- a/examples/calculator-java-junit4/pom.xml +++ b/examples/calculator-java-junit4/pom.xml @@ -9,7 +9,7 @@ calculator-java-junit4 jar - Examples: Calculator - Annotations - Junit4 + Examples: Calculator - Java - Annotations - Junit4 io.cucumber.examples.calculator diff --git a/examples/calculator-java-junit5/pom.xml b/examples/calculator-java-junit5/pom.xml index 2293162cc6..c35b104f07 100644 --- a/examples/calculator-java-junit5/pom.xml +++ b/examples/calculator-java-junit5/pom.xml @@ -1,4 +1,5 @@ - + 4.0.0 @@ -9,10 +10,10 @@ calculator-java-junit5 jar - Examples: Calculator - Annotations - Junit 5 + Examples: Calculator - Java - Annotations - Junit 5 - io.cucumber.calculator + io.cucumber.examples.calculator @@ -27,7 +28,7 @@ org.junit junit-bom - 5.10.1 + 5.12.2 pom import @@ -38,6 +39,13 @@ pom import + + org.assertj + assertj-bom + 3.27.3 + pom + import + @@ -57,11 +65,6 @@ junit-platform-suite test - - org.junit.jupiter - junit-jupiter-api - test - org.junit.platform junit-platform-console @@ -72,6 +75,11 @@ jackson-databind test + + org.assertj + assertj-core + test + @@ -106,14 +114,16 @@ - - - - - - - - + + + + + + + + diff --git a/examples/calculator-java-junit5/src/test/java/io/cucumber/examples/calculator/DateStepDefinitions.java b/examples/calculator-java-junit5/src/test/java/io/cucumber/examples/calculator/DateStepDefinitions.java index 4afa561411..7eee81ff73 100644 --- a/examples/calculator-java-junit5/src/test/java/io/cucumber/examples/calculator/DateStepDefinitions.java +++ b/examples/calculator-java-junit5/src/test/java/io/cucumber/examples/calculator/DateStepDefinitions.java @@ -6,7 +6,7 @@ import java.util.Date; -import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.assertj.core.api.Assertions.assertThat; public class DateStepDefinitions { @@ -25,6 +25,6 @@ public void I_ask_if_date_is_in_the_past(Date date) { @Then("^the result should be (yes|no)$") public void the_result_should_be(String expectedResult) { - assertEquals(expectedResult, result); + assertThat(result).isEqualTo(expectedResult); } } diff --git a/examples/calculator-java-junit5/src/test/java/io/cucumber/examples/calculator/RpnCalculatorSteps.java b/examples/calculator-java-junit5/src/test/java/io/cucumber/examples/calculator/RpnCalculatorSteps.java index 52dcb7031c..af1f313d36 100644 --- a/examples/calculator-java-junit5/src/test/java/io/cucumber/examples/calculator/RpnCalculatorSteps.java +++ b/examples/calculator-java-junit5/src/test/java/io/cucumber/examples/calculator/RpnCalculatorSteps.java @@ -11,7 +11,7 @@ import java.util.List; -import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.assertj.core.api.Assertions.assertThat; public class RpnCalculatorSteps { @@ -66,7 +66,7 @@ public void I_press(String what) { @Then("the result is {int}") public void the_result_is(double expected) { - assertEquals(expected, calc.value()); + assertThat(calc.value()).isEqualTo(expected); } @Given("the previous entries:") diff --git a/examples/calculator-java-junit5/src/test/java/io/cucumber/examples/calculator/ShoppingSteps.java b/examples/calculator-java-junit5/src/test/java/io/cucumber/examples/calculator/ShoppingSteps.java index e171998a6e..84086ae603 100644 --- a/examples/calculator-java-junit5/src/test/java/io/cucumber/examples/calculator/ShoppingSteps.java +++ b/examples/calculator-java-junit5/src/test/java/io/cucumber/examples/calculator/ShoppingSteps.java @@ -6,7 +6,7 @@ import java.util.List; -import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.assertj.core.api.Assertions.assertThat; public class ShoppingSteps { @@ -28,7 +28,7 @@ public void i_pay(int amount) { @Then("my change should be {}") public void my_change_should_be_(int change) { - assertEquals(-calc.value().intValue(), change); + assertThat(-calc.value().intValue()).isEqualTo(change); } static class Grocery { diff --git a/examples/calculator-java-testng/pom.xml b/examples/calculator-java-testng/pom.xml index b34bdf2531..4e6d3736f4 100644 --- a/examples/calculator-java-testng/pom.xml +++ b/examples/calculator-java-testng/pom.xml @@ -9,7 +9,7 @@ calculator-java-testng jar - Examples: Calculator - Annotations - TestNG + Examples: Calculator - Java - Annotations - TestNG io.cucumber.examples.calculator diff --git a/examples/calculator-java8-cli/pom.xml b/examples/calculator-java8-cli/pom.xml index 346d822ab4..f6c6d1254a 100644 --- a/examples/calculator-java8-cli/pom.xml +++ b/examples/calculator-java8-cli/pom.xml @@ -9,7 +9,7 @@ calculator-java8-cli jar - Examples: Calculator - Lambda - CLI + Examples: Calculator - Java - Lambda - CLI io.cucumber.examples.calculator diff --git a/examples/calculator-kotlin-junit5/pom.xml b/examples/calculator-kotlin-junit5/pom.xml index 3844011a8b..b7469eb5d9 100644 --- a/examples/calculator-kotlin-junit5/pom.xml +++ b/examples/calculator-kotlin-junit5/pom.xml @@ -1,24 +1,21 @@ - + 4.0.0 - examples io.cucumber + examples 7.23.0-SNAPSHOT calculator-kotlin-junit5 jar - Examples: Calculator - Kotlin - Annotations - Junit 5 - UTF-8 - 1.9.0 official - 5.12.2 io.cucumber.examples.calculator @@ -34,7 +31,14 @@ org.junit junit-bom - ${junit-jupiter.version} + 5.12.2 + pom + import + + + org.jetbrains.kotlin + kotlin-bom + 2.1.21 pom import @@ -42,20 +46,13 @@ - - io.cucumber - cucumber-java - test - org.jetbrains.kotlin kotlin-stdlib - ${kotlin.version} - org.jetbrains.kotlin - kotlin-test-junit - ${kotlin.version} + io.cucumber + cucumber-java test @@ -66,25 +63,6 @@ org.junit.platform junit-platform-suite - 1.12.2 - test - - - org.junit.jupiter - junit-jupiter - ${junit-jupiter.version} - test - - - org.junit.jupiter - junit-jupiter-api - ${junit-jupiter.version} - test - - - org.junit.jupiter - junit-jupiter-engine - ${junit-jupiter.version} test @@ -92,7 +70,10 @@ junit-platform-console test - + + org.jetbrains.kotlin + kotlin-test + @@ -103,7 +84,7 @@ org.jetbrains.kotlin kotlin-maven-plugin - ${kotlin.version} + 2.1.21 compile @@ -138,6 +119,7 @@ + org.apache.maven.plugins maven-antrun-plugin @@ -154,14 +136,16 @@ - - - - - - - - + + + + + + + + diff --git a/examples/calculator-kotlin-junit5/src/test/kotlin/io/cucumber/examples/calculator/RunCucumberKotlinTest.kt b/examples/calculator-kotlin-junit5/src/test/kotlin/io/cucumber/examples/calculator/RunCucumberKotlinTest.kt index b82457b0e0..bb3ab9d012 100644 --- a/examples/calculator-kotlin-junit5/src/test/kotlin/io/cucumber/examples/calculator/RunCucumberKotlinTest.kt +++ b/examples/calculator-kotlin-junit5/src/test/kotlin/io/cucumber/examples/calculator/RunCucumberKotlinTest.kt @@ -1,16 +1,18 @@ package io.cucumber.examples.calculator -import io.cucumber.junit.platform.engine.Constants +import io.cucumber.junit.platform.engine.Constants.GLUE_PROPERTY_NAME import org.junit.platform.suite.api.Suite import org.junit.platform.suite.api.IncludeEngines import org.junit.platform.suite.api.SelectPackages import org.junit.platform.suite.api.ConfigurationParameter -import org.junit.platform.suite.api.SelectClasspathResource - +/** + * Work around. Surefire does not use JUnits Test Engine discovery + * functionality. Alternatively execute the + * org.junit.platform.console.ConsoleLauncher with the maven-antrun-plugin. + */ @Suite @IncludeEngines("cucumber") @SelectPackages("io.cucumber.examples.calculator") -@ConfigurationParameter(key = Constants.GLUE_PROPERTY_NAME, value = "io.cucumber.examples.calculator") -@SelectClasspathResource("io.cucumber.examples.calculator") +@ConfigurationParameter(key = GLUE_PROPERTY_NAME, value = "io.cucumber.examples.calculator") class RunCucumberKotlinTest diff --git a/examples/pom.xml b/examples/pom.xml index 73c87a94f2..0a906407e0 100644 --- a/examples/pom.xml +++ b/examples/pom.xml @@ -17,9 +17,9 @@ calculator-java-junit4 calculator-java-junit5 calculator-java-testng + calculator-kotlin-junit5 spring-java-junit5 wicket-java-junit4 - calculator-kotlin-junit5 diff --git a/examples/spring-java-junit5/pom.xml b/examples/spring-java-junit5/pom.xml index 3848cf3647..580766fc8b 100644 --- a/examples/spring-java-junit5/pom.xml +++ b/examples/spring-java-junit5/pom.xml @@ -8,7 +8,7 @@ spring-java-junit5 - Examples: Spring Transactions - Java - Junit 5 + Examples: Spring Transactions - Java - Annotations - Junit 5 io.cucumber.examples.spring.application