From 09eea3413fc0d48e7e83b06cd12b9839a3ad97ab Mon Sep 17 00:00:00 2001 From: Love Leifland Date: Thu, 19 Dec 2024 15:31:08 +0100 Subject: [PATCH] Bump cucumber version --- pom.xml | 23 +++++++++++----- tools/grammar/pom.xml | 6 ----- .../opencypher/tools/tck/api/CypherTCK.scala | 15 ++++++----- .../tools/tck/api/PickleHelpers.scala | 2 +- .../tools/tck/api/ScenarioTest.scala | 20 +++++++------- .../tools/tck/api/groups/GroupTest.scala | 26 ++++++++----------- .../browser/cli/CountScenariosTest.scala | 20 ++++++-------- .../tck/inspection/diff/GroupDiffTest.scala | 20 ++++++-------- .../inspection/diff/ScenarioDiffTest.scala | 20 +++++++------- .../tck/inspection/diff/TckTreeDiffTest.scala | 22 ++++++---------- tools/tck-integrity-tests/pom.xml | 2 +- tools/tck-reporting/pom.xml | 12 +++++++++ .../cucumber/CucumberReportAdapter.java | 17 ++++++------ .../reporting/cucumber/model/TCKTestCase.java | 5 ++++ .../reporting/cucumber/model/TCKTestStep.java | 16 ++++++++++-- .../reporting/cucumber/ReportValidator.java | 15 ++--------- .../tck/reporting/cucumber/expected.json | 25 ++++++++++++++++++ 17 files changed, 148 insertions(+), 118 deletions(-) diff --git a/pom.xml b/pom.xml index 3329307ee5..5905110eae 100644 --- a/pom.xml +++ b/pom.xml @@ -30,11 +30,13 @@ 4.7.2 1.13 0.10.0 - 5.7.0 + 7.20.1 + 8.25.1 2.3.3 2.2 1.7.0 5.7.0 + 2.37.0 3.8.1 3.2.0 3.2.1 @@ -47,7 +49,7 @@ 1.8 1.4 2.3.30 - 2.11.3 + 2.18.2 ${project.rootdir}/ASL-2-header.txt 11 11 @@ -122,14 +124,15 @@ - io.cucumber - cucumber-core - ${dep.cucumber.version} + net.javacrumbs.json-unit + json-unit-assertj + ${dep.json-unit-asserth.version} + test io.cucumber - cucumber-gherkin-vintage + cucumber-core ${dep.cucumber.version} @@ -182,7 +185,13 @@ com.fasterxml.jackson.dataformat jackson-dataformat-xml - ${dep.jackson-dataformat-xml.version} + ${dep.jackson.version} + + + + com.fasterxml.jackson.core + jackson-databind + ${dep.jackson.version} diff --git a/tools/grammar/pom.xml b/tools/grammar/pom.xml index 9756a0f40a..20c496187a 100644 --- a/tools/grammar/pom.xml +++ b/tools/grammar/pom.xml @@ -86,12 +86,6 @@ 2.17.0 - - io.cucumber - cucumber-gherkin-vintage - true - - diff --git a/tools/tck-api/src/main/scala/org/opencypher/tools/tck/api/CypherTCK.scala b/tools/tck-api/src/main/scala/org/opencypher/tools/tck/api/CypherTCK.scala index 40fcc2c9ec..d42beeb43e 100644 --- a/tools/tck-api/src/main/scala/org/opencypher/tools/tck/api/CypherTCK.scala +++ b/tools/tck-api/src/main/scala/org/opencypher/tools/tck/api/CypherTCK.scala @@ -29,8 +29,8 @@ package org.opencypher.tools.tck.api import io.cucumber.core.gherkin import io.cucumber.core.gherkin.DataTableArgument -import io.cucumber.core.gherkin.DocStringArgument -import io.cucumber.core.gherkin.vintage.GherkinVintageFeatureParser +import io.cucumber.plugin.event.DocStringArgument +import io.cucumber.core.gherkin.messages.GherkinMessagesFeatureParser import org.opencypher.tools.tck.SideEffectOps.Diff import org.opencypher.tools.tck._ import org.opencypher.tools.tck.api.events.TCKEvents @@ -46,6 +46,7 @@ import java.net.URI import java.nio.charset.StandardCharsets import java.nio.file._ import java.util +import java.util.UUID import scala.annotation.tailrec import scala.collection.mutable.ListBuffer import scala.jdk.CollectionConverters._ @@ -58,7 +59,7 @@ object CypherTCK { val featuresPath = "/features" val featureSuffix = ".feature" - private lazy val parser = new GherkinVintageFeatureParser() + private lazy val parser = new GherkinMessagesFeatureParser() /** * Provides all the scenarios in the openCypher TCK. @@ -142,7 +143,7 @@ object CypherTCK { def apply(pickle: NameExtractedPickle): PickleGroupingKey = PickleGroupingKey(pickle.pickle.getKeyword, pickle.nameAndNumber) } - Try(parser.parse(featureFile.toUri, featureString, null)) match { + Try(parser.parse(featureFile.toUri, featureString, () => UUID.randomUUID)) match { case Success(featureOption) => if(featureOption.isPresent) { val feature = featureOption.get() @@ -156,7 +157,7 @@ object CypherTCK { case (_, included) => included.sortBy(_.pickle.getLocation.getLine) } - val featureName = feature.getName + val featureName = feature.getName.orElse("N/A") val scenarios = includedGroupedAndSorted.flatMap { case (PickleGroupingKey("Scenario Outline", _), pickles) => pickles.zipWithIndex.map { @@ -171,7 +172,7 @@ object CypherTCK { } else Feature(Seq[Scenario]()) case Failure(error) => - throw InvalidFeatureFormatException(s"Could not parse feature from ${featureFile.toAbsolutePath.toString}: ${error.getMessage}") + throw InvalidFeatureFormatException(s"Could not parse feature from ${featureFile.toAbsolutePath.toString}: ${error.getMessage}", error) } } @@ -470,7 +471,7 @@ case class ExpectError(errorType: String, phase: String, detail: String, source: } } -case class InvalidFeatureFormatException(message: String) extends RuntimeException(message) +case class InvalidFeatureFormatException(message: String, cause: Throwable = null) extends RuntimeException(message, cause) sealed trait QueryType diff --git a/tools/tck-api/src/main/scala/org/opencypher/tools/tck/api/PickleHelpers.scala b/tools/tck-api/src/main/scala/org/opencypher/tools/tck/api/PickleHelpers.scala index 65f9ec4902..6946de1e74 100644 --- a/tools/tck-api/src/main/scala/org/opencypher/tools/tck/api/PickleHelpers.scala +++ b/tools/tck-api/src/main/scala/org/opencypher/tools/tck/api/PickleHelpers.scala @@ -60,7 +60,7 @@ case object PickleStep { case class PickleLocation(line: Int, column: Int) case object PickleLocation { - def apply(location: io.cucumber.core.gherkin.Location): PickleLocation = { + def apply(location: io.cucumber.plugin.event.Location): PickleLocation = { PickleLocation(location.getLine, location.getColumn) } } diff --git a/tools/tck-api/src/test/scala/org/opencypher/tools/tck/api/ScenarioTest.scala b/tools/tck-api/src/test/scala/org/opencypher/tools/tck/api/ScenarioTest.scala index f614b4f611..61a4677790 100644 --- a/tools/tck-api/src/test/scala/org/opencypher/tools/tck/api/ScenarioTest.scala +++ b/tools/tck-api/src/test/scala/org/opencypher/tools/tck/api/ScenarioTest.scala @@ -39,12 +39,8 @@ class ScenarioTest extends AnyFunSuite with Matchers { val noPickleSteps = new util.ArrayList[io.cucumber.core.gherkin.Step]() val noPickleTags = new util.ArrayList[String]() - def location(line: Int, column: Int): io.cucumber.core.gherkin.Location = { - new io.cucumber.core.gherkin.Location() { - override def getLine: Int = line - - override def getColumn: Int = column - } + def location(line: Int, column: Int): io.cucumber.plugin.event.Location = { + new io.cucumber.plugin.event.Location(line, column) } def stringArgument(text: String, line: Int): io.cucumber.core.gherkin.DocStringArgument = { @@ -54,6 +50,8 @@ class ScenarioTest extends AnyFunSuite with Matchers { override def getContentType: String = "" override def getLine: Int = line + + override def getMediaType: String = "" } } @@ -63,15 +61,17 @@ class ScenarioTest extends AnyFunSuite with Matchers { override def getArgument: io.cucumber.core.gherkin.Argument = argument - override def getKeyWord: String = keyWord + override def getKeyword: String = keyWord override def getType: io.cucumber.core.gherkin.StepType = stepType - override def getPreviousGivenWhenThenKeyWord: String = "" + override def getPreviousGivenWhenThenKeyword: String = "" override def getText: String = text override def getId: String = id + + override def getLocation: io.cucumber.plugin.event.Location = new io.cucumber.plugin.event.Location(0, 0) } } @@ -94,9 +94,9 @@ class ScenarioTest extends AnyFunSuite with Matchers { override def getName: String = name - override def getLocation: io.cucumber.core.gherkin.Location = loc + override def getLocation: io.cucumber.plugin.event.Location = loc - override def getScenarioLocation: io.cucumber.core.gherkin.Location = loc + override def getScenarioLocation: io.cucumber.plugin.event.Location = loc override def getSteps: util.List[io.cucumber.core.gherkin.Step] = steps diff --git a/tools/tck-api/src/test/scala/org/opencypher/tools/tck/api/groups/GroupTest.scala b/tools/tck-api/src/test/scala/org/opencypher/tools/tck/api/groups/GroupTest.scala index 2a32e949bb..47ee602d7f 100644 --- a/tools/tck-api/src/test/scala/org/opencypher/tools/tck/api/groups/GroupTest.scala +++ b/tools/tck-api/src/test/scala/org/opencypher/tools/tck/api/groups/GroupTest.scala @@ -46,17 +46,9 @@ trait GroupTest extends Matchers { override val getName: String = "name" - override val getLocation: io.cucumber.core.gherkin.Location = new io.cucumber.core.gherkin.Location() { - override val getLine: Int = 1 + override val getLocation: io.cucumber.plugin.event.Location = new io.cucumber.plugin.event.Location(1,1) - override val getColumn: Int = 1 - } - - override val getScenarioLocation: io.cucumber.core.gherkin.Location = new io.cucumber.core.gherkin.Location() { - override val getLine: Int = 1 - - override val getColumn: Int = 1 - } + override val getScenarioLocation: io.cucumber.plugin.event.Location = new io.cucumber.plugin.event.Location(1,1) override val getSteps: util.List[io.cucumber.core.gherkin.Step] = new util.ArrayList[io.cucumber.core.gherkin.Step]() @@ -71,22 +63,26 @@ trait GroupTest extends Matchers { override val getLine: Int = 1 override val getArgument: io.cucumber.core.gherkin.Argument = new io.cucumber.core.gherkin.DocStringArgument() { - override val getContent: String = "text" + override def getContent: String = "text" + + override def getContentType: String = "" - override val getContentType: String = "" + override def getMediaType: String = "" - override val getLine: Int = 1 + override def getLine: Int = 1 } - override val getKeyWord: String = "keyWord" + override val getKeyword: String = "keyWord" override val getType: io.cucumber.core.gherkin.StepType = io.cucumber.core.gherkin.StepType.GIVEN - override val getPreviousGivenWhenThenKeyWord: String = "" + override val getPreviousGivenWhenThenKeyword: String = "" override val getText: String = "xyz" override val getId: String = "id" + + override def getLocation: io.cucumber.plugin.event.Location = new io.cucumber.plugin.event.Location(1, 1) } val dummySteps: List[Step] = List[Step](Dummy(dummyPickleStep), Measure(dummyPickleStep)) diff --git a/tools/tck-inspection/src/test/scala/org/opencypher/tools/tck/inspection/browser/cli/CountScenariosTest.scala b/tools/tck-inspection/src/test/scala/org/opencypher/tools/tck/inspection/browser/cli/CountScenariosTest.scala index 3ed4c02290..271929b9ed 100644 --- a/tools/tck-inspection/src/test/scala/org/opencypher/tools/tck/inspection/browser/cli/CountScenariosTest.scala +++ b/tools/tck-inspection/src/test/scala/org/opencypher/tools/tck/inspection/browser/cli/CountScenariosTest.scala @@ -48,17 +48,9 @@ class CountScenariosTest extends AnyFunSuite with Matchers { override def getName: String = "name" - override def getLocation: io.cucumber.core.gherkin.Location = new io.cucumber.core.gherkin.Location() { - override def getLine: Int = 1 - - override def getColumn: Int = 1 - } - - override def getScenarioLocation: io.cucumber.core.gherkin.Location = new io.cucumber.core.gherkin.Location() { - override def getLine: Int = 1 + override def getLocation: io.cucumber.plugin.event.Location = new io.cucumber.plugin.event.Location(1,1) - override def getColumn: Int = 1 - } + override def getScenarioLocation: io.cucumber.plugin.event.Location = new io.cucumber.plugin.event.Location(1,1) override def getSteps: util.List[io.cucumber.core.gherkin.Step] = new util.ArrayList[io.cucumber.core.gherkin.Step]() @@ -78,17 +70,21 @@ class CountScenariosTest extends AnyFunSuite with Matchers { override def getContentType: String = "" override def getLine: Int = 1 + + override def getMediaType: String = "" } - override def getKeyWord: String = "keyWord" + override def getKeyword: String = "keyWord" override def getType: io.cucumber.core.gherkin.StepType = io.cucumber.core.gherkin.StepType.GIVEN - override def getPreviousGivenWhenThenKeyWord: String = "" + override def getPreviousGivenWhenThenKeyword: String = "" override def getText: String = name override def getId: String = "id" + + override def getLocation: io.cucumber.plugin.event.Location = new io.cucumber.plugin.event.Location(1,1) } private val dummyPickleStep = namedDummyPickleStep("") diff --git a/tools/tck-inspection/src/test/scala/org/opencypher/tools/tck/inspection/diff/GroupDiffTest.scala b/tools/tck-inspection/src/test/scala/org/opencypher/tools/tck/inspection/diff/GroupDiffTest.scala index 47262bed07..74b7ce45d0 100644 --- a/tools/tck-inspection/src/test/scala/org/opencypher/tools/tck/inspection/diff/GroupDiffTest.scala +++ b/tools/tck-inspection/src/test/scala/org/opencypher/tools/tck/inspection/diff/GroupDiffTest.scala @@ -46,17 +46,9 @@ class GroupDiffTest extends AnyFunSuite with Matchers { override def getName: String = "name" - override def getLocation: io.cucumber.core.gherkin.Location = new io.cucumber.core.gherkin.Location() { - override def getLine: Int = 1 - - override def getColumn: Int = 1 - } - - override def getScenarioLocation: io.cucumber.core.gherkin.Location = new io.cucumber.core.gherkin.Location() { - override def getLine: Int = 1 + override def getLocation: io.cucumber.plugin.event.Location = new io.cucumber.plugin.event.Location(1,1) - override def getColumn: Int = 1 - } + override def getScenarioLocation: io.cucumber.plugin.event.Location = new io.cucumber.plugin.event.Location(1,1) override def getSteps: util.List[io.cucumber.core.gherkin.Step] = new util.ArrayList[io.cucumber.core.gherkin.Step]() @@ -76,17 +68,21 @@ class GroupDiffTest extends AnyFunSuite with Matchers { override def getContentType: String = "" override def getLine: Int = 1 + + override def getMediaType: String = "" } - override def getKeyWord: String = "keyWord" + override def getKeyword: String = "keyWord" override def getType: io.cucumber.core.gherkin.StepType = io.cucumber.core.gherkin.StepType.GIVEN - override def getPreviousGivenWhenThenKeyWord: String = "" + override def getPreviousGivenWhenThenKeyword: String = "" override def getText: String = name override def getId: String = "id" + + override def getLocation: io.cucumber.plugin.event.Location = new io.cucumber.plugin.event.Location(1,1) } private val dummyPickleStep = namedDummyPickleStep("") diff --git a/tools/tck-inspection/src/test/scala/org/opencypher/tools/tck/inspection/diff/ScenarioDiffTest.scala b/tools/tck-inspection/src/test/scala/org/opencypher/tools/tck/inspection/diff/ScenarioDiffTest.scala index b935a45189..7112a385fb 100644 --- a/tools/tck-inspection/src/test/scala/org/opencypher/tools/tck/inspection/diff/ScenarioDiffTest.scala +++ b/tools/tck-inspection/src/test/scala/org/opencypher/tools/tck/inspection/diff/ScenarioDiffTest.scala @@ -44,12 +44,8 @@ class ScenarioDiffTest extends AnyFunSuite with Matchers { val noPickleSteps = new util.ArrayList[io.cucumber.core.gherkin.Step]() val noPickleTags = new util.ArrayList[String]() - def location(line: Int, column: Int): io.cucumber.core.gherkin.Location = { - new io.cucumber.core.gherkin.Location() { - override def getLine: Int = line - - override def getColumn: Int = column - } + def location(line: Int, column: Int): io.cucumber.plugin.event.Location = { + new io.cucumber.plugin.event.Location(line,column) } def stringArgument(text: String, line: Int): io.cucumber.core.gherkin.DocStringArgument = { @@ -59,6 +55,8 @@ class ScenarioDiffTest extends AnyFunSuite with Matchers { override def getContentType: String = "" override def getLine: Int = line + + override def getMediaType: String = "" } } @@ -68,15 +66,17 @@ class ScenarioDiffTest extends AnyFunSuite with Matchers { override def getArgument: io.cucumber.core.gherkin.Argument = argument - override def getKeyWord: String = keyWord + override def getKeyword: String = keyWord override def getType: io.cucumber.core.gherkin.StepType = stepType - override def getPreviousGivenWhenThenKeyWord: String = "" + override def getPreviousGivenWhenThenKeyword: String = "" override def getText: String = text override def getId: String = id + + override def getLocation: io.cucumber.plugin.event.Location = new io.cucumber.plugin.event.Location(line, 1) } } @@ -99,9 +99,9 @@ class ScenarioDiffTest extends AnyFunSuite with Matchers { override def getName: String = name - override def getLocation: io.cucumber.core.gherkin.Location = loc + override def getLocation: io.cucumber.plugin.event.Location = loc - override def getScenarioLocation: io.cucumber.core.gherkin.Location = loc + override def getScenarioLocation: io.cucumber.plugin.event.Location = loc override def getSteps: util.List[io.cucumber.core.gherkin.Step] = steps diff --git a/tools/tck-inspection/src/test/scala/org/opencypher/tools/tck/inspection/diff/TckTreeDiffTest.scala b/tools/tck-inspection/src/test/scala/org/opencypher/tools/tck/inspection/diff/TckTreeDiffTest.scala index a9b4b24cda..5eb8ee9256 100644 --- a/tools/tck-inspection/src/test/scala/org/opencypher/tools/tck/inspection/diff/TckTreeDiffTest.scala +++ b/tools/tck-inspection/src/test/scala/org/opencypher/tools/tck/inspection/diff/TckTreeDiffTest.scala @@ -37,11 +37,9 @@ import org.opencypher.tools.tck.api.Step import org.opencypher.tools.tck.api.groups.Feature import org.opencypher.tools.tck.api.groups.Group import org.opencypher.tools.tck.api.groups.ScenarioCategory -import org.opencypher.tools.tck.api.groups.ScenarioOutline import org.opencypher.tools.tck.api.groups.Tag import org.opencypher.tools.tck.api.groups.TckTree import org.opencypher.tools.tck.api.groups.Total -import org.opencypher.tools.tck.inspection.diff import org.opencypher.tools.tck.inspection.diff.ScenarioDiffTag._ import org.scalatest.funsuite.AnyFunSuite import org.scalatest.matchers.should.Matchers @@ -54,17 +52,9 @@ class TckTreeDiffTest extends AnyFunSuite with Matchers { override def getName: String = "name" - override def getLocation: io.cucumber.core.gherkin.Location = new io.cucumber.core.gherkin.Location() { - override def getLine: Int = 1 - - override def getColumn: Int = 1 - } - - override def getScenarioLocation: io.cucumber.core.gherkin.Location = new io.cucumber.core.gherkin.Location() { - override def getLine: Int = 1 + override def getLocation: io.cucumber.plugin.event.Location = new io.cucumber.plugin.event.Location(1,1) - override def getColumn: Int = 1 - } + override def getScenarioLocation: io.cucumber.plugin.event.Location = new io.cucumber.plugin.event.Location(1,1) override def getSteps: util.List[io.cucumber.core.gherkin.Step] = new util.ArrayList[io.cucumber.core.gherkin.Step]() @@ -84,17 +74,21 @@ class TckTreeDiffTest extends AnyFunSuite with Matchers { override def getContentType: String = "" override def getLine: Int = 1 + + override def getMediaType: String = "" } - override def getKeyWord: String = "keyWord" + override def getKeyword: String = "keyWord" override def getType: io.cucumber.core.gherkin.StepType = io.cucumber.core.gherkin.StepType.GIVEN - override def getPreviousGivenWhenThenKeyWord: String = "" + override def getPreviousGivenWhenThenKeyword: String = "" override def getText: String = name override def getId: String = "id" + + override def getLocation: io.cucumber.plugin.event.Location = new io.cucumber.plugin.event.Location(1,1) } private val dummyPickleStep = namedDummyPickleStep("") diff --git a/tools/tck-integrity-tests/pom.xml b/tools/tck-integrity-tests/pom.xml index 2ed0c60ada..9457c06af2 100644 --- a/tools/tck-integrity-tests/pom.xml +++ b/tools/tck-integrity-tests/pom.xml @@ -115,7 +115,7 @@ io.cucumber cucumber-scala_${scala.binary.version} - ${dep.cucumber.version} + ${dep.cucumber-scala.version} test diff --git a/tools/tck-reporting/pom.xml b/tools/tck-reporting/pom.xml index 7a548826ea..84dabf419f 100644 --- a/tools/tck-reporting/pom.xml +++ b/tools/tck-reporting/pom.xml @@ -73,6 +73,18 @@ junit-vintage-engine test + + + net.javacrumbs.json-unit + json-unit-assertj + test + + + + com.fasterxml.jackson.core + jackson-databind + test + diff --git a/tools/tck-reporting/src/main/java/org/opencypher/tools/tck/reporting/cucumber/CucumberReportAdapter.java b/tools/tck-reporting/src/main/java/org/opencypher/tools/tck/reporting/cucumber/CucumberReportAdapter.java index 3f9314ad75..7b76e5f52d 100644 --- a/tools/tck-reporting/src/main/java/org/opencypher/tools/tck/reporting/cucumber/CucumberReportAdapter.java +++ b/tools/tck-reporting/src/main/java/org/opencypher/tools/tck/reporting/cucumber/CucumberReportAdapter.java @@ -29,13 +29,14 @@ import io.cucumber.core.options.CucumberPropertiesParser; import io.cucumber.core.options.PluginOption; -import io.cucumber.core.plugin.JSONFormatter; +import io.cucumber.core.plugin.JsonFormatter; import io.cucumber.plugin.EventListener; import io.cucumber.plugin.event.*; import io.cucumber.core.options.RuntimeOptions; -import java.io.FileWriter; +import java.io.FileOutputStream; import java.io.IOException; +import java.io.OutputStream; import java.net.URI; import java.time.Duration; import java.time.Instant; @@ -83,7 +84,7 @@ public void beforeAll(ExtensionContext context) { @Override public void afterAll(ExtensionContext context) throws Exception { - bus.handle(new TestRunFinished(Instant.now())); + bus.handle(new TestRunFinished(Instant.now(), new Result(Status.UNDEFINED, Duration.ofSeconds(1), null))); output.close(); } @@ -91,19 +92,19 @@ private void initCucumberPlugins() { Map properties = System.getProperties().entrySet().stream() .collect(Collectors.toMap(e -> (String) e.getKey(), e -> (String) e.getValue())); RuntimeOptions options = new CucumberPropertiesParser().parse(properties).build(); - Appendable appendable = options.plugins().stream() + final var appendable = options.plugins().stream() .filter(PluginOption.class::isInstance) .map(PluginOption.class::cast) - .filter(pluginOption -> pluginOption.pluginClass() == JSONFormatter.class) + .filter(pluginOption -> pluginOption.pluginClass() == JsonFormatter.class) .findFirst() - .map(pluginOption -> { + .map( pluginOption -> { try { - return (Appendable) new FileWriter(pluginOption.argument()); + return new FileOutputStream(pluginOption.argument()); } catch (IOException e) { throw new IllegalStateException("File " + pluginOption.argument() + " not found"); } }).orElse(System.out); - EventListener eventListener = new JSONFormatter(appendable); + EventListener eventListener = new JsonFormatter(appendable); eventListener.setEventPublisher(bus); } diff --git a/tools/tck-reporting/src/main/java/org/opencypher/tools/tck/reporting/cucumber/model/TCKTestCase.java b/tools/tck-reporting/src/main/java/org/opencypher/tools/tck/reporting/cucumber/model/TCKTestCase.java index 38188abae2..611d7089ac 100644 --- a/tools/tck-reporting/src/main/java/org/opencypher/tools/tck/reporting/cucumber/model/TCKTestCase.java +++ b/tools/tck-reporting/src/main/java/org/opencypher/tools/tck/reporting/cucumber/model/TCKTestCase.java @@ -86,4 +86,9 @@ public URI getUri() { public UUID getId() { return UUID.nameUUIDFromBytes(pickle.getId().getBytes()); } + + @Override + public io.cucumber.plugin.event.Location getLocation() { + return pickle.getLocation(); + } } diff --git a/tools/tck-reporting/src/main/java/org/opencypher/tools/tck/reporting/cucumber/model/TCKTestStep.java b/tools/tck-reporting/src/main/java/org/opencypher/tools/tck/reporting/cucumber/model/TCKTestStep.java index ed355cee94..f4771f426f 100644 --- a/tools/tck-reporting/src/main/java/org/opencypher/tools/tck/reporting/cucumber/model/TCKTestStep.java +++ b/tools/tck-reporting/src/main/java/org/opencypher/tools/tck/reporting/cucumber/model/TCKTestStep.java @@ -35,10 +35,12 @@ import java.net.URI; import java.util.ArrayList; import java.util.List; +import java.util.UUID; public class TCKTestStep implements PickleStepTestStep { private Step step; private URI uri; + private final UUID id = UUID.randomUUID(); public TCKTestStep(Step step, URI uri) { this.step = step; @@ -88,8 +90,8 @@ public StepArgument getArgument() { } @Override - public String getKeyWord() { - return step.getKeyWord(); + public String getKeyword() { + return step.getKeyword(); } @Override @@ -101,6 +103,11 @@ public String getText() { public int getLine() { return step.getLine(); } + + @Override + public io.cucumber.plugin.event.Location getLocation() { + return step.getLocation(); + } }; } @@ -108,4 +115,9 @@ public int getLine() { public String getCodeLocation() { return ""; } + + @Override + public UUID getId() { + return id; + } } diff --git a/tools/tck-reporting/src/test/java/org/opencypher/tools/tck/reporting/cucumber/ReportValidator.java b/tools/tck-reporting/src/test/java/org/opencypher/tools/tck/reporting/cucumber/ReportValidator.java index 019d43c945..1c6f4f5c16 100644 --- a/tools/tck-reporting/src/test/java/org/opencypher/tools/tck/reporting/cucumber/ReportValidator.java +++ b/tools/tck-reporting/src/test/java/org/opencypher/tools/tck/reporting/cucumber/ReportValidator.java @@ -28,7 +28,7 @@ package org.opencypher.tools.tck.reporting.cucumber; import static java.nio.file.Files.readAllBytes; -import static org.junit.jupiter.api.Assertions.assertEquals; +import static net.javacrumbs.jsonunit.assertj.JsonAssertions.assertThatJson; import java.nio.file.Files; import java.nio.file.Path; @@ -51,17 +51,6 @@ public void afterAll(ExtensionContext extensionContext) throws Exception { String expected = CucumberReportAdapterTest.getResource("expected.json"); String actual = new String(readAllBytes(cucumberReport)); - assertEquals( - ignoreTimeAndDuration(expected), - ignoreTimeAndDuration(actual)); - } - - /** - * duration 0 == no duration. See `cucumber.runtime.formatter.JSONFormatter` - */ - private String ignoreTimeAndDuration(String report) { - return report. - replaceAll("\n\\s*\"duration\":\\s*\\d+\\s*,", ""). - replaceAll("\n\\s*\"start_timestamp\":\\s*\"[\\w:.-]*\"\\s*,", ""); + assertThatJson(actual).isEqualTo(expected); } } diff --git a/tools/tck-reporting/src/test/resources/org/opencypher/tools/tck/reporting/cucumber/expected.json b/tools/tck-reporting/src/test/resources/org/opencypher/tools/tck/reporting/cucumber/expected.json index 5a6524a18f..b14c61d5c5 100644 --- a/tools/tck-reporting/src/test/resources/org/opencypher/tools/tck/reporting/cucumber/expected.json +++ b/tools/tck-reporting/src/test/resources/org/opencypher/tools/tck/reporting/cucumber/expected.json @@ -9,9 +9,11 @@ "id": "foo;return-literal", "type": "scenario", "keyword": "Scenario", + "start_timestamp": "${json-unit.any-string}", "steps": [ { "result": { + "duration": "${json-unit.any-number}", "status": "passed" }, "line": 32, @@ -26,6 +28,7 @@ "Producing some output 1\n" ], "result": { + "duration": "${json-unit.any-number}", "status": "passed" }, "line": 33, @@ -41,6 +44,7 @@ }, { "result": { + "duration": "${json-unit.any-number}", "status": "passed" }, "line": 37, @@ -67,6 +71,7 @@ "+labels: 0\n-labels: 0\n+nodes: 0\n-nodes: 0\n+properties: 0\n-properties: 0\n+relationships: 0\n-relationships: 0" ], "result": { + "duration": "${json-unit.any-number}", "status": "passed" }, "line": 40, @@ -85,9 +90,11 @@ "id": "foo;fail", "type": "scenario", "keyword": "Scenario", + "start_timestamp": "${json-unit.any-string}", "steps": [ { "result": { + "duration": "${json-unit.any-number}", "status": "passed" }, "line": 43, @@ -99,6 +106,7 @@ }, { "result": { + "duration": "${json-unit.any-number}", "status": "passed" }, "line": 44, @@ -114,6 +122,7 @@ }, { "result": { + "duration": "${json-unit.any-number}", "status": "passed" }, "line": 48, @@ -128,6 +137,7 @@ "+labels: 0\n-labels: 0\n+nodes: 0\n-nodes: 0\n+properties: 0\n-properties: 0\n+relationships: 0\n-relationships: 0" ], "result": { + "duration": "${json-unit.any-number}", "status": "passed" }, "line": 48, @@ -146,9 +156,11 @@ "id": "foo;outline-test;;2", "type": "scenario", "keyword": "Scenario Outline", + "start_timestamp": "${json-unit.any-string}", "steps": [ { "result": { + "duration": "${json-unit.any-number}", "status": "passed" }, "line": 51, @@ -163,6 +175,7 @@ "Producing some output 1\n" ], "result": { + "duration": "${json-unit.any-number}", "status": "passed" }, "line": 52, @@ -178,6 +191,7 @@ }, { "result": { + "duration": "${json-unit.any-number}", "status": "passed" }, "line": 56, @@ -204,6 +218,7 @@ "+labels: 0\n-labels: 0\n+nodes: 0\n-nodes: 0\n+properties: 0\n-properties: 0\n+relationships: 0\n-relationships: 0" ], "result": { + "duration": "${json-unit.any-number}", "status": "passed" }, "line": 59, @@ -222,9 +237,11 @@ "id": "foo;outline-test;;3", "type": "scenario", "keyword": "Scenario Outline", + "start_timestamp": "${json-unit.any-string}", "steps": [ { "result": { + "duration": "${json-unit.any-number}", "status": "passed" }, "line": 51, @@ -239,6 +256,7 @@ "Producing some output 2\n" ], "result": { + "duration": "${json-unit.any-number}", "status": "passed" }, "line": 52, @@ -254,6 +272,7 @@ }, { "result": { + "duration": "${json-unit.any-number}", "status": "passed" }, "line": 56, @@ -280,6 +299,7 @@ "+labels: 0\n-labels: 0\n+nodes: 0\n-nodes: 0\n+properties: 0\n-properties: 0\n+relationships: 0\n-relationships: 0" ], "result": { + "duration": "${json-unit.any-number}", "status": "passed" }, "line": 59, @@ -298,9 +318,11 @@ "id": "foo;outline-test;;4", "type": "scenario", "keyword": "Scenario Outline", + "start_timestamp": "${json-unit.any-string}", "steps": [ { "result": { + "duration": "${json-unit.any-number}", "status": "passed" }, "line": 51, @@ -315,6 +337,7 @@ "Producing some output 3\n" ], "result": { + "duration": "${json-unit.any-number}", "status": "passed" }, "line": 52, @@ -330,6 +353,7 @@ }, { "result": { + "duration": "${json-unit.any-number}", "status": "passed" }, "line": 56, @@ -356,6 +380,7 @@ "+labels: 0\n-labels: 0\n+nodes: 0\n-nodes: 0\n+properties: 0\n-properties: 0\n+relationships: 0\n-relationships: 0" ], "result": { + "duration": "${json-unit.any-number}", "status": "passed" }, "line": 59,