All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.yag.punner.report.TestResults.kt Maven / Gradle / Ivy

Go to download

Punner is a parallel JUnit test runner and maven plugin which can speed up your unit test.

There is a newer version: 0.9.17
Show newest version
package com.github.yag.punner.report

import com.github.yag.punner.core.ResultType
import com.github.yag.punner.core.TestCase
import com.github.yag.punner.core.TestResult

/**
 *
 */
class TestResults(val data: Map = LinkedHashMap()) : Iterable {

    val wallTime : Long by lazy {
        val start = data.values.map { it.startTime }.min()?:throw IllegalStateException()
        val end = data.values.map { it.stopTime }.max()?:throw IllegalStateException()

        end - start
    }

    val timeSaved : Long by lazy {
        data.map { it.value.cost() }.sum() - wallTime
    }

    val testCount = data.size

    val successCount = data.count { it.value.type == ResultType.SUCCESS }

    val errorCount = data.count { it.value.type == ResultType.ERROR }

    val failureCount = data.count { it.value.type == ResultType.FAILURE }

    val skippedCount = data.count { it.value.type == ResultType.SKIPPED }

    val timeUsed = data.map { it.value.cost() }.sum()

    val allPackages : List by lazy {
        data.map { it.key.packageName }.toSet().toList()
    }

    val allClasses : List by lazy {
        data.map { it.key.testClass.name }.toSet().toList()
    }

    fun getTestResults(prefix: String) : TestResults {
        return TestResults(data.filter {
            it.key.testClass.name.startsWith(prefix)
        }.toMutableMap())
    }

    fun getClasses(packageName: String) : List {
        return data.filter { it.key.packageName == packageName }.map { it.key.className }.toSet().toList()
    }


    override fun iterator(): Iterator {
        return data.values.iterator()
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy