mirror of https://github.com/sbt/sbt.git
Merge pull request #1364 from scalatest/test-result-acc-count
Accumulate Test Count
This commit is contained in:
commit
af70a895de
|
|
@ -197,7 +197,11 @@ object Tests {
|
||||||
val tasks = runnables.map { case (name, test) => toTask(loader, name, test, tags) }
|
val tasks = runnables.map { case (name, test) => toTask(loader, name, test, tags) }
|
||||||
tasks.join.map(_.foldLeft(Map.empty[String, SuiteResult]) {
|
tasks.join.map(_.foldLeft(Map.empty[String, SuiteResult]) {
|
||||||
case (sum, e) =>
|
case (sum, e) =>
|
||||||
sum ++ e
|
val merged = sum.toSeq ++ e.toSeq
|
||||||
|
val grouped = merged.groupBy(_._1)
|
||||||
|
grouped.mapValues(_.map(_._2).foldLeft(SuiteResult.Empty) {
|
||||||
|
case (resultSum, result) => resultSum + result
|
||||||
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -207,7 +211,14 @@ object Tests {
|
||||||
taggedBase flatMap {
|
taggedBase flatMap {
|
||||||
case (name, (result, nested)) =>
|
case (name, (result, nested)) =>
|
||||||
val nestedRunnables = createNestedRunnables(loader, fun, nested)
|
val nestedRunnables = createNestedRunnables(loader, fun, nested)
|
||||||
toTasks(loader, nestedRunnables, tags).map(_.updated(name, result))
|
toTasks(loader, nestedRunnables, tags).map { currentResultMap =>
|
||||||
|
val newResult =
|
||||||
|
currentResultMap.get(name) match {
|
||||||
|
case Some(currentResult) => currentResult + result
|
||||||
|
case None => result
|
||||||
|
}
|
||||||
|
currentResultMap.updated(name, newResult)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,9 +28,21 @@ trait TestsListener extends TestReportListener {
|
||||||
|
|
||||||
/** Provides the overall `result` of a group of tests (a suite) and test counts for each result type. */
|
/** Provides the overall `result` of a group of tests (a suite) and test counts for each result type. */
|
||||||
final class SuiteResult(
|
final class SuiteResult(
|
||||||
val result: TestResult.Value,
|
val result: TestResult.Value,
|
||||||
val passedCount: Int, val failureCount: Int, val errorCount: Int,
|
val passedCount: Int, val failureCount: Int, val errorCount: Int,
|
||||||
val skippedCount: Int, val ignoredCount: Int, val canceledCount: Int, val pendingCount: Int)
|
val skippedCount: Int, val ignoredCount: Int, val canceledCount: Int, val pendingCount: Int) {
|
||||||
|
def +(other: SuiteResult): SuiteResult = {
|
||||||
|
val combinedTestResult =
|
||||||
|
(result, other.result) match {
|
||||||
|
case (TestResult.Passed, TestResult.Passed) => TestResult.Passed
|
||||||
|
case (_, TestResult.Error) => TestResult.Error
|
||||||
|
case (TestResult.Error, _) => TestResult.Error
|
||||||
|
case _ => TestResult.Failed
|
||||||
|
}
|
||||||
|
new SuiteResult(combinedTestResult, passedCount + other.passedCount, failureCount + other.failureCount, errorCount + other.errorCount, skippedCount + other.skippedCount,
|
||||||
|
ignoredCount + other.ignoredCount, canceledCount + other.canceledCount, pendingCount + other.pendingCount)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
object SuiteResult {
|
object SuiteResult {
|
||||||
/** Computes the overall result and counts for a suite with individual test results in `events`. */
|
/** Computes the overall result and counts for a suite with individual test results in `events`. */
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue