From 7f34c22b88a74f30c7a07c714fecfb3241ac9712 Mon Sep 17 00:00:00 2001 From: Ronald Holshausen Date: Sat, 17 Oct 2020 15:55:45 +1100 Subject: [PATCH] fix: merge in results so we don't lose results with multiple interactions #1128 --- .../provider/junit/ArticlesContractTest.java | 2 ++ .../provider/reporters/MarkdownReporter.kt | 28 +++++++++++-------- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/provider/junit/src/test/java/au/com/dius/pact/provider/junit/ArticlesContractTest.java b/provider/junit/src/test/java/au/com/dius/pact/provider/junit/ArticlesContractTest.java index 12dfd40b0b..9ecd1fa51b 100644 --- a/provider/junit/src/test/java/au/com/dius/pact/provider/junit/ArticlesContractTest.java +++ b/provider/junit/src/test/java/au/com/dius/pact/provider/junit/ArticlesContractTest.java @@ -5,6 +5,7 @@ import au.com.dius.pact.provider.junitsupport.Provider; import au.com.dius.pact.provider.junitsupport.State; import au.com.dius.pact.provider.junitsupport.StateChangeAction; +import au.com.dius.pact.provider.junitsupport.VerificationReports; import au.com.dius.pact.provider.junitsupport.loader.PactFolder; import au.com.dius.pact.provider.junitsupport.target.Target; import au.com.dius.pact.provider.junitsupport.target.TestTarget; @@ -26,6 +27,7 @@ @RunWith(PactRunner.class) @Provider("ArticlesProvider") @PactFolder("src/test/resources/wildcards") +@VerificationReports({"console", "markdown"}) public class ArticlesContractTest { private static final Logger LOGGER = LoggerFactory.getLogger(ArticlesContractTest.class); diff --git a/provider/src/main/kotlin/au/com/dius/pact/provider/reporters/MarkdownReporter.kt b/provider/src/main/kotlin/au/com/dius/pact/provider/reporters/MarkdownReporter.kt index 2dd35e7b35..e22fc373e6 100644 --- a/provider/src/main/kotlin/au/com/dius/pact/provider/reporters/MarkdownReporter.kt +++ b/provider/src/main/kotlin/au/com/dius/pact/provider/reporters/MarkdownReporter.kt @@ -74,6 +74,7 @@ class MarkdownReporter( this.provider = provider reportDir!!.mkdirs() reportFile = File(reportDir, provider.name + ext) + events.clear() } override fun finaliseReport() { @@ -138,7 +139,7 @@ class MarkdownReporter( val document = parser.parseReader(BufferedReader(FileReader(reportFile))) val (consumer: IConsumerInfo?, state) = consumerAndStatus(document) - + val header = events.find { it.type == "reportVerificationForConsumer" }?.contents?.substring(2)?.trim() if (consumer != null) { var consumerSection: Node? = null for (child in document.children) { @@ -146,7 +147,7 @@ class MarkdownReporter( updateSummary(child.next, consumer, state) } - if (child is Heading && child.text.startsWith("Verifying a pact between _" + consumer.name)) { + if (child is Heading && child.text.contains(header.toString())) { consumerSection = child } } @@ -157,20 +158,25 @@ class MarkdownReporter( document.appendChild(section) } } else { - val prevChild = consumerSection.previous var child = consumerSection.next - consumerSection.unlink() while (child != null && child !is Heading) { - val currentChild = child child = child.next - currentChild.unlink() } - child = prevChild - for (event in events) { - val section = parser.parseReader(StringReader(event.contents)) - child!!.insertAfter(section) - child = section + if (child == null) { + for (event in events) { + if (event.type != "reportVerificationForConsumer") { + val section = parser.parseReader(StringReader(event.contents)) + document.appendChild(section) + } + } + } else { + for (event in events) { + if (event.type != "reportVerificationForConsumer") { + val section = parser.parseReader(StringReader(event.contents)) + child.insertBefore(section) + } + } } } }