diff --git a/doc/changes/changes_4.10.0.md b/doc/changes/changes_4.10.0.md index 578880bf..35f12da0 100644 --- a/doc/changes/changes_4.10.0.md +++ b/doc/changes/changes_4.10.0.md @@ -17,6 +17,7 @@ Each release now includes an SPDX 3 SBOM for the product JAR and a SHA-256 check ## Bugfixes * #582: Fixed the Markdown importer silently dropping all specification items after a fenced code block that directly follows a section title. +* #577: Fixed the Gherkin importer dropping a scenario when it directly follows another tagged scenario, with no boundary line between them. ## Documentation diff --git a/importer/gherkin/src/main/java/org/itsallcode/openfasttrace/importer/gherkin/GherkinLineConsumer.java b/importer/gherkin/src/main/java/org/itsallcode/openfasttrace/importer/gherkin/GherkinLineConsumer.java index 1c0fb7de..5bf5ee4b 100644 --- a/importer/gherkin/src/main/java/org/itsallcode/openfasttrace/importer/gherkin/GherkinLineConsumer.java +++ b/importer/gherkin/src/main/java/org/itsallcode/openfasttrace/importer/gherkin/GherkinLineConsumer.java @@ -72,6 +72,17 @@ public void readLine(final int lineNumber, final String line) } if (this.importingScenario) { + if (line.trim().startsWith("@")) + { + // A tag line is a Gherkin block boundary [dsn~gherkin.streaming-import~1] just as much as + // Scenario/Feature/Rule/Background/Examples are: it starts the metadata for the next + // scenario [dsn~gherkin.id-detection~1]. Without ending the current scenario here, this + // line would be swallowed as its description instead, and the next scenario would never + // get a pending id. + endScenario(); + readMetadata(lineNumber, line); + return; + } if (!line.trim().startsWith("#") && !line.trim().isEmpty()) { this.listener.appendDescription(line + System.lineSeparator()); diff --git a/importer/gherkin/src/test/java/org/itsallcode/openfasttrace/importer/gherkin/GherkinImporterTest.java b/importer/gherkin/src/test/java/org/itsallcode/openfasttrace/importer/gherkin/GherkinImporterTest.java index 5c46b47d..7e068126 100644 --- a/importer/gherkin/src/test/java/org/itsallcode/openfasttrace/importer/gherkin/GherkinImporterTest.java +++ b/importer/gherkin/src/test/java/org/itsallcode/openfasttrace/importer/gherkin/GherkinImporterTest.java @@ -300,6 +300,31 @@ void testImportsScenariosWithDuplicateIds() hasProperty("title", is("Second login")))); } + // [utest->dsn~gherkin.streaming-import~1] + // [utest->dsn~gherkin.id-detection~1] + @Test + void testImportsConsecutiveTaggedScenariosWithoutAnInterveningBoundary() + { + final List items = importText(""" + @id:scn~first~1 + # Needs: itest + Scenario: First scenario + Given a precondition + + @id:scn~second~1 + # Needs: itest + Scenario: Second scenario + Given another precondition + """); + + assertAll( + () -> assertThat(items, contains( + hasProperty("id", hasToString("scn~first~1")), + hasProperty("id", hasToString("scn~second~1")))), + () -> assertThat(items.get(0).getDescription(), is("Given a precondition")), + () -> assertThat(items.get(1).getDescription(), is("Given another precondition"))); + } + // [utest->dsn~gherkin.comment-coverage-tags~1] @Test void testImportsCommentCoverageTagsButIgnoresExecutableCoverageTags()