-
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.
Add overhead time to junit test case report (#684)
* Add overhead time to junit test case report * Omit mergeTestTimes if used new api results
- Loading branch information
Showing
10 changed files
with
74 additions
and
43 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
17 changes: 15 additions & 2 deletions
17
test_runner/src/main/kotlin/ftl/reports/api/CreateTestSuitOverviewData.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 |
---|---|---|
@@ -1,20 +1,33 @@ | ||
package ftl.reports.api | ||
|
||
import com.google.api.services.toolresults.model.TestCase | ||
import com.google.api.services.toolresults.model.TestSuiteOverview | ||
import ftl.reports.api.data.TestExecutionData | ||
import ftl.reports.api.data.TestSuiteOverviewData | ||
|
||
internal fun TestExecutionData.createTestSuitOverviewData(): TestSuiteOverviewData { | ||
val skipped = step.testExecutionStep.testSuiteOverviews.first().skippedCount ?: 0 | ||
val overview: TestSuiteOverview = step.testExecutionStep.testSuiteOverviews.first() | ||
val skipped: Int = overview.skippedCount ?: 0 | ||
return TestSuiteOverviewData( | ||
total = testCases.size + skipped, | ||
errors = testCases.countErrors(), | ||
failures = testCases.countFailures(), | ||
flakes = testCases.countFlakes(), | ||
skipped = skipped | ||
skipped = skipped, | ||
elapsedTime = overview.elapsedTime.millis(), | ||
overheadTime = getOverheadTime(overview, testCases) | ||
) | ||
} | ||
|
||
private fun List<TestCase>.countErrors() = count { !it.flaky && it.status == "error" } | ||
private fun List<TestCase>.countFailures() = count { !it.flaky && it.status == "failed" } | ||
private fun List<TestCase>.countFlakes() = count { it.flaky } | ||
|
||
private fun getOverheadTime( | ||
overview: TestSuiteOverview, | ||
testCases: List<TestCase> | ||
) = if (testCases.isEmpty()) | ||
0.0 else | ||
(overview.elapsedTime.millis() - testCases.sumTime()) / testCases.size | ||
|
||
private fun List<TestCase>.sumTime(): Double = sumByDouble { it.elapsedTime.millis() } |
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