Skip to content

Commit

Permalink
#829 Show robo test information
Browse files Browse the repository at this point in the history
  • Loading branch information
Piotr Adamczyk committed Jun 29, 2020
1 parent 0c195cc commit bae8463
Showing 1 changed file with 24 additions and 38 deletions.
62 changes: 24 additions & 38 deletions test_runner/src/main/kotlin/ftl/json/SavedMatrix.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package ftl.json

import com.google.api.services.testing.model.TestMatrix
import com.google.api.services.toolresults.model.Outcome
import ftl.android.AndroidCatalog
import ftl.android.AndroidCatalog.isVirtualDevice
import ftl.gc.GcToolResults
import ftl.reports.api.createTestExecutionDataListAsync
import ftl.reports.api.createTestSuitOverviewData
Expand Down Expand Up @@ -86,67 +86,53 @@ class SavedMatrix(matrix: TestMatrix) {
}

private fun updateFinishedMatrixData(matrix: TestMatrix) {
val testExecutionData = matrix.testExecutions.createTestExecutionDataListAsync()
val initial = TestSuiteOverviewData(0, 0, 0, 0, 0, 0.0, 0.0)
// details
val testExecutionsData = matrix.testExecutions.createTestExecutionDataListAsync().prepareForJUnitResult()
val summedTestSuiteOverviewData =
testExecutionData.prepareForJUnitResult().fold(initial) { sum, test -> sum + test.createTestSuitOverviewData() }

testExecutionData
.prepareForJUnitResult()
.forEach {
updatedFinishedInfo(
stepOutcome = GcToolResults.getExecutionResult(it.testExecution).outcome,
isVirtualDevice = AndroidCatalog.isVirtualDevice(
it.testExecution.environment.androidDevice,
matrix.projectId.orEmpty()
),
testSuiteOverviewData = summedTestSuiteOverviewData,
billableMinutes = it.step.testExecutionStep?.testTiming?.testProcessDuration?.seconds
?.let { testTimeSeconds -> Billing.billableMinutes(testTimeSeconds) }
)
testExecutionsData.fold(TestSuiteOverviewData(0, 0, 0, 0, 0, 0.0, 0.0)) { sum, test ->
sum + test.createTestSuitOverviewData()
}

// old method
/* data
.prepareForJUnitResult()
testExecutionsData
.forEach {
updatedFinishedInfo(
stepOutcome = GcToolResults.getExecutionResult(it.testExecution).outcome,
isVirtualDevice = AndroidCatalog.isVirtualDevice(
it.testExecution.environment.androidDevice,
matrix.projectId.orEmpty()
testSuiteOverviewData = summedTestSuiteOverviewData,
isRoboTests = it.testExecution.testSpecification.androidRoboTest != null,
isVirtualDevice = isVirtualDevice(
device = it.testExecution.environment.androidDevice,
projectId = matrix.projectId.orEmpty()
),
testSuiteOverviewData = it.createTestSuitOverviewData(),
billableMinutes = it.step.testExecutionStep?.testTiming?.testProcessDuration?.seconds
?.let { testTimeSeconds -> Billing.billableMinutes(testTimeSeconds) }
)
}*/
}
}

private fun updatedFinishedInfo(
stepOutcome: Outcome?,
isVirtualDevice: Boolean,
testSuiteOverviewData: TestSuiteOverviewData?,
isRoboTests: Boolean,
isVirtualDevice: Boolean,
billableMinutes: Long?
) {
updateOutcome(stepOutcome)
updateOutcomeDetails(stepOutcome, testSuiteOverviewData)
updateOutcomeDetails(stepOutcome, testSuiteOverviewData, isRoboTests)
billableMinutes?.let { updateBillableMinutes(it, isVirtualDevice) }
}

private fun updateOutcome(stepOutcome: Outcome?) {
outcome = when {
// the matrix outcome is failure if any step fails
// if the matrix outcome is already set to failure then we can ignore the other step outcomes.
// inconclusive is treated as a failure
outcome == failure || outcome == inconclusive -> return
else -> stepOutcome?.summary ?: outcome
}
// the matrix outcome is failure if any step fails
// if the matrix outcome is already set to failure then we can ignore the other step outcomes.
// inconclusive is treated as a failure
if (outcome != failure && outcome != inconclusive) outcome = stepOutcome?.summary ?: outcome
}

private fun updateOutcomeDetails(stepOutcome: Outcome?, testSuiteOverviewData: TestSuiteOverviewData?) {
outcomeDetails = stepOutcome?.getDetails(testSuiteOverviewData) ?: "---"
private fun updateOutcomeDetails(
stepOutcome: Outcome?,
testSuiteOverviewData: TestSuiteOverviewData?,
isRoboTests: Boolean
) {
outcomeDetails = if (isRoboTests) "Robo test" else (stepOutcome?.getDetails(testSuiteOverviewData) ?: "---")
}

private fun updateBillableMinutes(billableMinutes: Long, isVirtualDevice: Boolean) {
Expand Down

0 comments on commit bae8463

Please sign in to comment.