Skip to content

Commit 8997d01

Browse files
author
Ronald Holshausen
committedApr 4, 2020
chore: list out unverified interactions when test results are received
1 parent 20dfeaa commit 8997d01

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed
 

‎provider/pact-jvm-provider/src/main/kotlin/au/com/dius/pact/provider/TestResultAccumulator.kt

+8-4
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ object DefaultTestResultAccumulator : TestResultAccumulator, KLogging() {
4444
} else {
4545
interactionResults[interactionHash] = testResult.merge(testExecutionResult)
4646
}
47-
if (allInteractionsVerified(pact, interactionResults)) {
47+
val unverifiedInteractions = unverifiedInteractions(pact, interactionResults)
48+
if (unverifiedInteractions.isEmpty()) {
4849
logger.debug {
4950
"All interactions for Pact ${pact.provider.name}-${pact.consumer.name} have a verification result"
5051
}
@@ -58,7 +59,10 @@ object DefaultTestResultAccumulator : TestResultAccumulator, KLogging() {
5859
}
5960
testResults.remove(pactHash)
6061
} else {
61-
logger.info { "Not all of the ${pact.interactions.size} were verified." }
62+
logger.warn { "Not all of the ${pact.interactions.size} were verified. The following were missing:" }
63+
unverifiedInteractions.forEach {
64+
logger.warn { " ${it.description}" }
65+
}
6266
}
6367
}
6468

@@ -83,9 +87,9 @@ object DefaultTestResultAccumulator : TestResultAccumulator, KLogging() {
8387

8488
private fun lookupProviderTag(): String? = System.getProperty("pact.provider.tag")
8589

86-
fun allInteractionsVerified(pact: Pact<out Interaction>, results: MutableMap<Int, TestResult>): Boolean {
90+
fun unverifiedInteractions(pact: Pact<out Interaction>, results: MutableMap<Int, TestResult>): List<Interaction> {
8791
logger.debug { "Number of interactions #${pact.interactions.size} and results: ${results.values}" }
88-
return pact.interactions.all { results.containsKey(calculateInteractionHash(it)) }
92+
return pact.interactions.filter { !results.containsKey(calculateInteractionHash(it)) }
8993
}
9094

9195
override fun clearTestResult(pact: Pact<out Interaction>) {

‎provider/pact-jvm-provider/src/test/groovy/au/com/dius/pact/provider/TestResultAccumulatorSpec.groovy

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class TestResultAccumulatorSpec extends Specification {
4040
@SuppressWarnings('LineLength')
4141
def 'allInteractionsVerified returns #result when #condition'() {
4242
expect:
43-
testResultAccumulator.allInteractionsVerified(pact, results) == result
43+
testResultAccumulator.unverifiedInteractions(pact, results).empty == result
4444

4545
where:
4646

0 commit comments

Comments
 (0)
Please sign in to comment.