File tree Expand file tree Collapse file tree 6 files changed +93
-1
lines changed
examples/examples-scalatest/src
main/scala/cucumber/examples/scalacalculator
cucumber/examples/scalacalculator
scala/cucumber/examples/scalacalculator Expand file tree Collapse file tree 6 files changed +93
-1
lines changed Original file line number Diff line number Diff line change @@ -94,7 +94,8 @@ lazy val root = (project in file("."))
9494 integrationTestsPicoContainer.projectRefs ++
9595 integrationTestsScalatest.projectRefs ++
9696 examplesJunit4.projectRefs ++
97- examplesJunit5.projectRefs: _*
97+ examplesJunit5.projectRefs ++
98+ examplesScalatest.projectRefs: _*
9899 )
99100
100101// Main project
@@ -275,6 +276,20 @@ lazy val examplesJunit5 = (projectMatrix in file("examples/examples-junit5"))
275276 .dependsOn(cucumberScala % Test )
276277 .jvmPlatform(scalaVersions = Seq (scala3, scala213))
277278
279+ lazy val examplesScalatest = (projectMatrix in file(" examples/examples-scalatest" ))
280+ .settings(commonSettings)
281+ .settings(scalatestSbtSupport)
282+ .settings(
283+ name := " scala-examples-scalatest" ,
284+ libraryDependencies ++= Seq (
285+ " org.scalatest" %% " scalatest" % scalatestVersion % Test
286+ ),
287+ publishArtifact := false
288+ )
289+ .dependsOn(cucumberScala % Test )
290+ .dependsOn(cucumberScalatest % Test )
291+ .jvmPlatform(scalaVersions = Seq (scala3, scala213))
292+
278293// Version policy check
279294
280295ThisBuild / versionScheme := Some (" early-semver" )
Original file line number Diff line number Diff line change 1+ package cucumber .examples .scalacalculator
2+
3+ import scala .collection .mutable .Queue
4+
5+ sealed trait Arg
6+
7+ object Arg {
8+ implicit def op (s : String ): Op = Op (s)
9+ implicit def value (v : Double ): Val = Val (v)
10+ }
11+
12+ case class Op (value : String ) extends Arg
13+ case class Val (value : Double ) extends Arg
14+
15+ class RpnCalculator {
16+ private val stack = Queue .empty[Double ]
17+
18+ private def op (f : (Double , Double ) => Double ) =
19+ stack += f(stack.dequeue(), stack.dequeue())
20+
21+ def push (arg : Arg ): Unit = {
22+ arg match {
23+ case Op (" +" ) => op(_ + _)
24+ case Op (" -" ) => op(_ - _)
25+ case Op (" *" ) => op(_ * _)
26+ case Op (" /" ) => op(_ / _)
27+ case Val (value) => stack += value
28+ case _ => ()
29+ }
30+ ()
31+ }
32+
33+ def value : Double = stack.head
34+ }
Original file line number Diff line number Diff line change 1+ @foo
2+ Feature : Basic Arithmetic
3+
4+ Scenario : Adding
5+ # Try to change one of the values below to provoke a failure
6+ When I add 4.0 and 5.0
7+ Then the result is 9.0
Original file line number Diff line number Diff line change 1+ cucumber.plugin =pretty
2+ # Workaround for https://github.com/sbt/sbt-jupiter-interface/issues/142
3+ # See also https://github.com/cucumber/cucumber-jvm/pull/3023
4+ cucumber.junit-platform.discovery.as-root-engine =false
Original file line number Diff line number Diff line change 1+ package cucumber .examples .scalacalculator
2+
3+ import io .cucumber .scala .{EN , ScalaDsl , Scenario }
4+
5+ class RpnCalculatorStepDefinitions extends ScalaDsl with EN {
6+
7+ val calc = new RpnCalculator
8+
9+ When (""" I add {double} and {double}""" ) { (arg1 : Double , arg2 : Double ) =>
10+ calc push arg1
11+ calc push arg2
12+ calc push " +"
13+ }
14+
15+ Then (" the result is {double}" ) { (expected : Double ) =>
16+ assert(math.abs(expected - calc.value) < 0.001 , s " Expected $expected but got ${calc.value}" )
17+ }
18+
19+ Before (" not @foo" ) { (scenario : Scenario ) =>
20+ println(s " Runs before scenarios *not* tagged with @foo ( ${scenario.getId}) " )
21+ }
22+ }
Original file line number Diff line number Diff line change 1+ package cucumber .examples .scalacalculator
2+
3+ import io .cucumber .scalatest .{CucumberOptions , CucumberSuite }
4+
5+ @ CucumberOptions (
6+ features = Array (" classpath:cucumber/examples/scalacalculator" ),
7+ glue = Array (" cucumber.examples.scalacalculator" ),
8+ plugin = Array (" pretty" )
9+ )
10+ class RunCukesTest extends CucumberSuite
You can’t perform that action at this time.
0 commit comments