diff --git a/main/actions/src/main/scala/sbt/Tests.scala b/main/actions/src/main/scala/sbt/Tests.scala index 486361565..22ae552cc 100644 --- a/main/actions/src/main/scala/sbt/Tests.scala +++ b/main/actions/src/main/scala/sbt/Tests.scala @@ -197,7 +197,11 @@ object Tests { val tasks = runnables.map { case (name, test) => toTask(loader, name, test, tags) } tasks.join.map(_.foldLeft(Map.empty[String, SuiteResult]) { 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 { case (name, (result, 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) + } } } diff --git a/testing/src/main/scala/sbt/TestReportListener.scala b/testing/src/main/scala/sbt/TestReportListener.scala index 5a3e34072..d0d1d9562 100644 --- a/testing/src/main/scala/sbt/TestReportListener.scala +++ b/testing/src/main/scala/sbt/TestReportListener.scala @@ -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. */ final class SuiteResult( - val result: TestResult.Value, - val passedCount: Int, val failureCount: Int, val errorCount: Int, - val skippedCount: Int, val ignoredCount: Int, val canceledCount: Int, val pendingCount: Int) + val result: TestResult.Value, + val passedCount: Int, val failureCount: Int, val errorCount: 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 { /** Computes the overall result and counts for a suite with individual test results in `events`. */