Skip to content

Commit

Permalink
Compare JUnit5Summary objects for equality.
Browse files Browse the repository at this point in the history
  • Loading branch information
schmonz committed Jun 28, 2024
1 parent ab487ff commit 62e397f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
8 changes: 1 addition & 7 deletions src/main/kotlin/com/schmonz/greencently/Greenness.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,6 @@ package com.schmonz.greencently
import com.schmonz.greencently.summary.JUnit5Summary

class Greenness(private val actuallyRan: JUnit5Summary, private val couldHaveRun: JUnit5Summary) {
private fun enoughTestsRan() =
actuallyRan.testCount == couldHaveRun.testCount

private fun allTestsGreen() =
actuallyRan.anyTestsGreen && !actuallyRan.anyTestsRed

fun isTotal() =
enoughTestsRan() && allTestsGreen()
actuallyRan == couldHaveRun
}
15 changes: 15 additions & 0 deletions src/main/kotlin/com/schmonz/greencently/summary/JUnit5Summary.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,19 @@ class JUnit5Summary(testPlan: TestPlan, internal val anyTestsRed: Boolean, inter
)
}
}

override fun equals(other: Any?): Boolean {
if (this === other) return true
if (other !is JUnit5Summary) return false
if (testCount == other.testCount && anyTestsRed == other.anyTestsRed && anyTestsGreen == other.anyTestsGreen)
return true
return false
}

override fun hashCode(): Int {
var result = anyTestsRed.hashCode()
result = 31 * result + anyTestsGreen.hashCode()
result = 31 * result + testCount.hashCode()
return result
}
}

0 comments on commit 62e397f

Please sign in to comment.