From 9d7236ab938a55871ea81b65e45c663ec21e0b14 Mon Sep 17 00:00:00 2001 From: Branko Juric Date: Tue, 5 Nov 2024 12:45:06 +1100 Subject: [PATCH] DSL cleanup --- .sbtopts | 1 + build.sbt | 2 + .../scala/gwen/web/eval/WebEngineTest.scala | 129 +++++++----------- 3 files changed, 50 insertions(+), 82 deletions(-) diff --git a/.sbtopts b/.sbtopts index 9e315b51..e4dab483 100644 --- a/.sbtopts +++ b/.sbtopts @@ -1,3 +1,4 @@ -J-XX:MaxMetaspaceSize=1024M -J-Dsbt.sourcemode=true -J-Djansi.passthrough=true +-J-Xshare:off diff --git a/build.sbt b/build.sbt index 76abe0a4..bac690b9 100644 --- a/build.sbt +++ b/build.sbt @@ -71,3 +71,5 @@ Compile / packageBin / mappings ++= Seq( ) Test / parallelExecution := false + +Test / testOptions += Tests.Argument("-oF") diff --git a/src/test/scala/gwen/web/eval/WebEngineTest.scala b/src/test/scala/gwen/web/eval/WebEngineTest.scala index e764ae3a..b119e876 100644 --- a/src/test/scala/gwen/web/eval/WebEngineTest.scala +++ b/src/test/scala/gwen/web/eval/WebEngineTest.scala @@ -966,18 +966,14 @@ class WebEngineTest extends BaseTest with Matchers with MockitoSugar with Before verify(mockTopScope, times(3)).set("", "value", false) } - """my property """"" should "evaluate" in { - List("is", "will be").zipWithIndex.foreach { case (x, i) => - evaluate(s"""my gwen.property-$i property $x "value-$i"""") - Settings.get(s"gwen.property-$i") should be (s"value-$i") - } + """my property is """"" should "evaluate" in { + evaluate(s"""my gwen.property-0 property is "value-0"""") + Settings.get(s"gwen.property-0") should be (s"value-0") } - """my setting """"" should "evaluate" in { - List("is", "will be").zipWithIndex.foreach { case (x, i) => - evaluate(s"""my gwen.setting-$i setting $x "value-$i"""") - Settings.get(s"gwen.setting-$i") should be (s"value-$i") - } + """my setting is """"" should "evaluate" in { + evaluate(s"""my gwen.setting-0 setting is "value-0"""") + Settings.get(s"gwen.setting-0") should be (s"value-0") } "I reset my property" should "evaluate" in { @@ -990,55 +986,43 @@ class WebEngineTest extends BaseTest with Matchers with MockitoSugar with Before Settings.getOpt(s"gwen.web") should be (None) } - """ be defined by javascript """"" should "evaluate" in { + """ is defined by javascript """"" should "evaluate" in { doReturn(mockTopScope).when(envState).topScope - List("is", "will be").zipWithIndex.foreach { case (x, i) => - evaluate(s"""attribute-$i $x defined by javascript "expression-$i"""") - verify(mockTopScope).set(s"attribute-$i/javascript", s"expression-$i", false) - } + evaluate(s"""attribute-0 is defined by javascript "expression-0"""") + verify(mockTopScope).set(s"attribute-0/javascript", s"expression-0", false) } - """ be defined by property """"" should "evaluate" in { - List("is", "will be").zipWithIndex.foreach { case (x, i) => - withSetting(s"name-$i", s"$i") { - evaluate(s"""attribute-$i $x defined by property "name-$i"""") - verify(mockTopScope).set(s"attribute-$i", s"$i", false) - } + """ is defined by property """"" should "evaluate" in { + withSetting(s"name-0", "0") { + evaluate(s"""attribute-0 is defined by property "name-0"""") + verify(mockTopScope).set(s"attribute-0", "0", false) } } - """ be defined by setting """"" should "evaluate" in { - List("is", "will be").zipWithIndex.foreach { case (x, i) => - withSetting(s"name-$i", s"$i") { - evaluate(s"""attribute-$i $x defined by setting "name-$i"""") - verify(mockTopScope).set(s"attribute-$i", s"$i", false) - } + """ is defined by setting """"" should "evaluate" in { + withSetting(s"name-0", "0") { + evaluate(s"""attribute-0 is defined by setting "name-0"""") + verify(mockTopScope).set(s"attribute-0", "0", false) } } - """ be defined by system process """"" should "evaluate" in { + """ is defined by system process """"" should "evaluate" in { doReturn(mockTopScope).when(envState).topScope - List("is", "will be").zipWithIndex.foreach { case (x, i) => - evaluate(s"""attribute-$i $x defined by system process "process-$i"""") - verify(mockTopScope).set(s"attribute-$i/sysproc", s"process-$i", false) - } + evaluate(s"""attribute-0 is defined by system process "process-0"""") + verify(mockTopScope).set(s"attribute-0/sysproc", s"process-0", false) } - """ be defined by system process "" delimited by """"" should "evaluate" in { + """ is defined by system process "" delimited by """"" should "evaluate" in { doReturn(mockTopScope).when(envState).topScope - List("is", "will be").zipWithIndex.foreach { case (x, i) => - evaluate(s"""attribute-$i $x defined by system process "process-$i" delimited by ","""") - verify(mockTopScope).set(s"attribute-$i/sysproc", s"process-$i", false) - verify(mockTopScope).set(s"attribute-$i/delimiter", s",", false) - } + evaluate(s"""attribute-0 is defined by system process "process-0" delimited by ","""") + verify(mockTopScope).set(s"attribute-0/sysproc", s"process-0", false) + verify(mockTopScope).set(s"attribute-0/delimiter", s",", false) } - """ be defined by file """"" should "evaluate" in { + """ is defined by file """"" should "evaluate" in { doReturn(mockTopScope).when(envState).topScope - List("is", "will be").zipWithIndex.foreach { case (x, i) => - evaluate(s"""attribute-$i $x defined by file "filepath-$i"""") - verify(mockTopScope).set(s"attribute-$i/file", s"filepath-$i", false) - } + evaluate(s"""attribute-0 is defined by file "filepath-0"""") + verify(mockTopScope).set(s"attribute-0/file", s"filepath-0", false) } """ is defined by the in by xpath """"" should "evaluate" in { @@ -1048,42 +1032,27 @@ class WebEngineTest extends BaseTest with Matchers with MockitoSugar with Before verify(mockTopScope).set("/xpath/source", s"", false) verify(mockTopScope).set("/xpath/targetType", x, false) verify(mockTopScope).set("/xpath/expression", s"", false) + reset(mockTopScope) } } - """ will be defined by the in by xpath """"" should "evaluate" in { - doReturn(mockTopScope).when(envState).topScope - List("text", "node", "nodeset").zipWithIndex.foreach { case (x, i) => - evaluate(s""" will be defined by the $x in by xpath """"") - verify(mockTopScope).set("/xpath/source", s"", false) - verify(mockTopScope).set("/xpath/targetType", x, false) - verify(mockTopScope).set("/xpath/expression", s"", false) - } - } - - """ defined in by regex """"" should "evaluate" in { + """ is defined in by regex """"" should "evaluate" in { doReturn(mockTopScope).when(envState).topScope - List("is", "will be").zipWithIndex.foreach { case (x, i) => - evaluate(s""" $x defined in by regex """"") - verify(mockTopScope).set(s"/regex/source", s"", false) - verify(mockTopScope).set(s"/regex/expression", s"", false) - } + evaluate(s""" is defined in by regex """"") + verify(mockTopScope).set(s"/regex/source", s"", false) + verify(mockTopScope).set(s"/regex/expression", s"", false) } - """ defined in by json path """"" should "evaluate" in { + """ is defined in by json path """"" should "evaluate" in { doReturn(mockTopScope).when(envState).topScope - List("is", "will be").zipWithIndex.foreach { case (x, i) => - evaluate(s""" $x defined in by json path """"") - verify(mockTopScope).set(s"/json path/source", s"", false) - verify(mockTopScope).set(s"/json path/expression", s"", false) - } + evaluate(s""" is defined in by json path """"") + verify(mockTopScope).set(s"/json path/source", s"", false) + verify(mockTopScope).set(s"/json path/expression", s"", false) } - """ """"" should "evaluate" in { - List("is", "will be").zipWithIndex.foreach { case (x, i) => - evaluate(s""" $x """"") - verify(mockTopScope).set(s"", s"", false) - } + """ is """"" should "evaluate" in { + evaluate(s""" is """"") + verify(mockTopScope).set(s"", s"", false) } "@Timeout('1s') I wait for text" should "evaluate" in { @@ -1604,28 +1573,24 @@ class WebEngineTest extends BaseTest with Matchers with MockitoSugar with Before } } - """ defined by sql "" in the database""" should "evaluate" in { + """ is defined by sql "" in the database""" should "evaluate" in { doReturn(mockTopScope).when(envState).topScope withSetting("gwen.db..driver", "driver") { withSetting("gwen.db..url", "url") { - List("is", "will be").foreach { x => - evaluate(s""" $x defined by sql "" in the database""") - } - verify(mockTopScope, times(2)).set(s"/sql/selectStmt", "", false) - verify(mockTopScope, times(2)).set(s"/sql/dbName", "", false) + evaluate(s""" is defined by sql "" in the database""") + verify(mockTopScope).set(s"/sql/selectStmt", "", false) + verify(mockTopScope).set(s"/sql/dbName", "", false) } } } - """ defined in the database by sql """"" should "evaluate" in { + """ is defined in the database by sql """"" should "evaluate" in { doReturn(mockTopScope).when(envState).topScope withSetting("gwen.db..driver", "driver") { withSetting("gwen.db..url", "url") { - List("is", "will be").foreach { x => - evaluate(s""" $x defined in the database by sql """"") - } - verify(mockTopScope, times(2)).set(s"/sql/selectStmt", "", false) - verify(mockTopScope, times(2)).set(s"/sql/dbName", "", false) + evaluate(s""" is defined in the database by sql """"") + verify(mockTopScope).set(s"/sql/selectStmt", "", false) + verify(mockTopScope).set(s"/sql/dbName", "", false) } } }