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

net.serenitybdd.reports.model.TestResultsByFeature.kt Maven / Gradle / Ivy

There is a newer version: 4.2.3
Show newest version
package net.serenitybdd.reports.model

import net.thucydides.model.domain.TestOutcome
import net.thucydides.model.reports.TestOutcomes

class TestResultsByFeature(val featureName: String,
                           val issues: List,
                           val scenarios: List) {

    fun getDescription(): String = featureName + issueDescription()

    private fun issueDescription(): String = if (issues.isEmpty()) "" else " (" + issues.joinToString(",") + ")"

    companion object {
        fun from(testOutcomes: TestOutcomes): List {
//            val outcomesGroupedByFeature = testOutcomes.tests.groupBy { it.userStory }
            val outcomesGroupedByFeature = testOutcomes.testCases.groupBy { it.userStory }
            return outcomesGroupedByFeature.keys.map { userStory ->
                TestResultsByFeature(userStory.name,
                        issuesIn(outcomesGroupedByFeature.getOrDefault(userStory, listOf())),
                        scenariosIn(outcomesGroupedByFeature.getOrDefault(userStory, listOf())))
            }.sortedBy { it.featureName }
        }

        private fun scenariosIn(testOutcomes: List): List =
                testOutcomes.map { outcome -> ScenarioSummary.ofAllScenariosIn(outcome) }

        private fun issuesIn(testOutcomes: List): List =
                testOutcomes.map { outcome -> outcome.issues.toList() }.flatten().distinct()
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy