net.serenitybdd.reports.model.TestResultsByFeature.kt Maven / Gradle / Ivy
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()
}
}