-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Reflect gclouds outcome for robo tests (#1124)
* Implement fix for robo outcome * Address PR review comments
- Loading branch information
1 parent
6fe3299
commit feecdc9
Showing
8 changed files
with
208 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
126 changes: 126 additions & 0 deletions
126
test_runner/src/test/kotlin/ftl/reports/outcome/CreateMatrixOutcomeSummaryKtTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
package ftl.reports.outcome | ||
|
||
import com.google.api.services.toolresults.model.Environment | ||
import com.google.api.services.toolresults.model.Step | ||
import io.mockk.every | ||
import io.mockk.mockkStatic | ||
import io.mockk.unmockkAll | ||
import kotlin.reflect.full.createInstance | ||
import org.junit.After | ||
import org.junit.Assert.assertEquals | ||
import org.junit.Before | ||
import org.junit.Test | ||
|
||
class CreateMatrixOutcomeSummaryKtTest { | ||
|
||
@Before | ||
fun setUp() { | ||
mockkStatic("ftl.reports.outcome.UtilKt") | ||
mockkStatic("ftl.reports.outcome.BillableMinutesKt") | ||
} | ||
|
||
@After | ||
fun tearDown() = unmockkAll() | ||
|
||
@Test | ||
fun `should create TestOutcome list for success robo test - from environments`() { | ||
val env: Environment = make { | ||
environmentResult = make { | ||
outcome = make { summary = "success" } | ||
} | ||
} | ||
every { env.axisValue() } returns "anyDevice" | ||
val context = TestOutcomeContext( | ||
matrixId = "anyMatrix", | ||
projectId = "anyProject", | ||
testTimeout = Long.MAX_VALUE, | ||
steps = emptyList(), | ||
isRoboTest = true, | ||
environments = listOf(env) | ||
) | ||
|
||
val (_, result) = context.createMatrixOutcomeSummary() | ||
|
||
assertEquals("---", result[0].details) | ||
assertEquals("anyDevice", result[0].device) | ||
assertEquals("success", result[0].outcome) | ||
} | ||
|
||
@Test | ||
fun `should create TestOutcome list for failed robo test - from environments`() { | ||
val env: Environment = make { | ||
environmentResult = make { | ||
outcome = make { | ||
summary = "failure" | ||
failureDetail = make { failedRoboscript = true } | ||
} | ||
} | ||
} | ||
every { env.axisValue() } returns "anyDevice" | ||
val context = TestOutcomeContext( | ||
matrixId = "anyMatrix", | ||
projectId = "anyProject", | ||
testTimeout = Long.MAX_VALUE, | ||
steps = emptyList(), | ||
isRoboTest = true, | ||
environments = listOf(env) | ||
) | ||
|
||
val (_, result) = context.createMatrixOutcomeSummary() | ||
|
||
assertEquals("Test failed to run", result[0].details) | ||
assertEquals("anyDevice", result[0].device) | ||
assertEquals("failure", result[0].outcome) | ||
} | ||
|
||
@Test | ||
fun `should create TestOutcome list for success robo test - from steps`() { | ||
val steps: List<Step> = listOf(make { | ||
outcome = make { summary = "success" } | ||
}) | ||
every { steps[0].axisValue() } returns "anyDevice" | ||
every { steps.calculateAndroidBillableMinutes(any(), any()) } returns make() | ||
val context = TestOutcomeContext( | ||
matrixId = "anyMatrix", | ||
projectId = "anyProject", | ||
testTimeout = Long.MAX_VALUE, | ||
steps = steps, | ||
isRoboTest = true, | ||
environments = emptyList() | ||
) | ||
|
||
val (_, result) = context.createMatrixOutcomeSummary() | ||
|
||
assertEquals("---", result[0].details) | ||
assertEquals("anyDevice", result[0].device) | ||
assertEquals("success", result[0].outcome) | ||
} | ||
|
||
@Test | ||
fun `should create TestOutcome list for failed robo test - from steps`() { | ||
val steps: List<Step> = listOf(make { | ||
outcome = make { | ||
summary = "failure" | ||
failureDetail = make { failedRoboscript = true } | ||
} | ||
}) | ||
every { steps[0].axisValue() } returns "anyDevice" | ||
every { steps.calculateAndroidBillableMinutes(any(), any()) } returns make() | ||
val context = TestOutcomeContext( | ||
matrixId = "anyMatrix", | ||
projectId = "anyProject", | ||
testTimeout = Long.MAX_VALUE, | ||
steps = steps, | ||
isRoboTest = true, | ||
environments = emptyList() | ||
) | ||
|
||
val (_, result) = context.createMatrixOutcomeSummary() | ||
|
||
assertEquals("Test failed to run", result[0].details) | ||
assertEquals("anyDevice", result[0].device) | ||
assertEquals("failure", result[0].outcome) | ||
} | ||
} | ||
|
||
private inline fun <reified T : Any> make(block: T.() -> Unit = {}): T = T::class.createInstance().apply(block) |